refactor(cmake): selectively remove sources on win32

Signed-off-by: Roberto Scolaro <roberto.scolaro21@gmail.com>
This commit is contained in:
Roberto Scolaro
2023-11-02 19:11:48 +01:00
committed by poiana
parent 115729a86a
commit b9d7eb7ab3
4 changed files with 13 additions and 11 deletions

View File

@@ -53,9 +53,7 @@ set(
logger.cpp
falco_outputs.cpp
outputs_file.cpp
outputs_program.cpp
outputs_stdout.cpp
outputs_syslog.cpp
event_drops.cpp
stats_writer.cpp
versions_info.cpp
@@ -90,6 +88,14 @@ if(USE_BUNDLED_DEPS)
list(APPEND FALCO_DEPENDENCIES yamlcpp)
endif()
if(NOT WIN32)
list(
APPEND FALCO_SOURCES
outputs_program.cpp
outputs_syslog.cpp
)
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT MINIMAL_BUILD)
list(
APPEND FALCO_SOURCES

View File

@@ -27,9 +27,11 @@ limitations under the License.
#include "watchdog.h"
#include "outputs_file.h"
#include "outputs_program.h"
#include "outputs_stdout.h"
#if !defined(_WIN32)
#include "outputs_program.h"
#include "outputs_syslog.h"
#endif
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
#include "outputs_http.h"
#include "outputs_grpc.h"
@@ -100,10 +102,12 @@ void falco_outputs::add_output(falco::outputs::config oc)
{
oo = new falco::outputs::output_stdout();
}
#ifndef _WIN32
else if(oc.name == "syslog")
{
oo = new falco::outputs::output_syslog();
}
#endif
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
else if(oc.name == "http")
{

View File

@@ -20,7 +20,6 @@ limitations under the License.
void falco::outputs::output_program::open_pfile()
{
#ifndef _WIN32
if(m_pfile == nullptr)
{
m_pfile = popen(m_oc.options["program"].c_str(), "w");
@@ -30,7 +29,6 @@ void falco::outputs::output_program::open_pfile()
setvbuf(m_pfile, NULL, _IONBF, 0);
}
}
#endif
}
void falco::outputs::output_program::output(const message *msg)
@@ -47,13 +45,11 @@ void falco::outputs::output_program::output(const message *msg)
void falco::outputs::output_program::cleanup()
{
#ifndef _WIN32
if(m_pfile != nullptr)
{
pclose(m_pfile);
m_pfile = nullptr;
}
#endif
}
void falco::outputs::output_program::reopen()

View File

@@ -16,14 +16,10 @@ limitations under the License.
*/
#include "outputs_syslog.h"
#ifndef _WIN32
#include <syslog.h>
#endif
void falco::outputs::output_syslog::output(const message *msg)
{
#ifndef _WIN32
// Syslog output should not have any trailing newline
::syslog(msg->priority, "%s", msg->msg.c_str());
#endif
}