Skip to content

Commit 274c5d4

Browse files
leogrpoiana
authored andcommitted
build: drop WIN32 exclusion from http_output, webserver, and metrics gates
Rely solely on MINIMAL_BUILD and EMSCRIPTEN as semantic guards instead of explicit platform checks. MSVC builds are unaffected since CompilerFlags.cmake forces MINIMAL_BUILD=ON, keeping these features disabled. Non-MSVC Windows toolchains (MinGW, clang) can now build with http_output if curl and OpenSSL are available. Signed-off-by: Leonardo Grasso <me@leonardograsso.com>
1 parent 45f7cee commit 274c5d4

10 files changed

Lines changed: 15 additions & 21 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,7 @@ include(njson)
175175
# yaml-cpp
176176
include(yaml-cpp)
177177

178-
if(NOT WIN32
179-
AND NOT MINIMAL_BUILD
180-
AND NOT EMSCRIPTEN
181-
)
178+
if(NOT MINIMAL_BUILD AND NOT EMSCRIPTEN)
182179
# OpenSSL
183180
include(openssl)
184181

userspace/engine/falco_utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ limitations under the License.
2222
#include <libsinsp/utils.h>
2323

2424
#include <re2/re2.h>
25-
#if !defined(_WIN32) and !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
25+
#if !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
2626
#include <openssl/evp.h>
2727
#endif
2828
#include <cstring>
@@ -136,7 +136,7 @@ uint64_t parse_prometheus_interval(std::string interval_str) {
136136
return interval;
137137
}
138138

139-
#if !defined(_WIN32) and !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
139+
#if !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
140140
std::string calculate_file_sha256sum(const std::string& filename) {
141141
std::ifstream file(filename, std::ios::binary);
142142
if(!file.is_open()) {

userspace/engine/falco_utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ limitations under the License.
2626
namespace falco::utils {
2727
uint64_t parse_prometheus_interval(std::string interval_str);
2828

29-
#if !defined(_WIN32) and !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
29+
#if !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
3030
std::string calculate_file_sha256sum(const std::string& filename);
3131
#endif
3232

userspace/falco/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,7 @@ if(NOT WIN32)
8383
target_sources(falco_application PRIVATE outputs_program.cpp outputs_syslog.cpp)
8484
endif()
8585

86-
if(NOT WIN32
87-
AND NOT EMSCRIPTEN
88-
AND NOT MINIMAL_BUILD
89-
)
86+
if(NOT EMSCRIPTEN AND NOT MINIMAL_BUILD)
9087
target_sources(falco_application PRIVATE outputs_http.cpp falco_metrics.cpp webserver.cpp)
9188

9289
list(APPEND FALCO_INCLUDE_DIRECTORIES FALCO_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}")

userspace/falco/app/actions/load_rules_files.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ falco::app::run_result falco::app::actions::load_rules_files(falco::app::state&
8282
if(res->has_warnings()) {
8383
falco_logger::log(falco_logger::level::WARNING, res->as_string(true, rc) + "\n");
8484
}
85-
#if !defined(_WIN32) and !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
85+
#if !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
8686
s.config->m_loaded_rules_filenames_sha256sum.insert(
8787
{filename, falco::utils::calculate_file_sha256sum(filename)});
8888
#endif

userspace/falco/app/actions/start_webserver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ limitations under the License.
1717

1818
#include "actions.h"
1919

20-
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
20+
#if !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
2121
#include "webserver.h"
2222
#endif
2323

2424
using namespace falco::app;
2525
using namespace falco::app::actions;
2626

2727
falco::app::run_result falco::app::actions::start_webserver(falco::app::state& state) {
28-
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
28+
#if !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
2929
if(state.is_capture_mode() || !state.config->m_webserver_enabled) {
3030
return run_result::ok();
3131
}
@@ -50,7 +50,7 @@ falco::app::run_result falco::app::actions::start_webserver(falco::app::state& s
5050
}
5151

5252
falco::app::run_result falco::app::actions::stop_webserver(falco::app::state& state) {
53-
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
53+
#if !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
5454
if(state.is_capture_mode() || !state.config->m_webserver_enabled) {
5555
return run_result::ok();
5656
}

userspace/falco/app/state.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ limitations under the License.
2323
#include "restart_handler.h"
2424
#include "../configuration.h"
2525
#include "../stats_writer.h"
26-
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
26+
#if !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
2727
#include "../webserver.h"
2828
#endif
2929

@@ -109,7 +109,7 @@ struct state {
109109
// Helper responsible for watching of handling hot application restarts
110110
std::shared_ptr<restart_handler> restarter;
111111

112-
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
112+
#if !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
113113
falco_webserver webserver;
114114
#endif
115115
// Set by start_webserver to start prometheus metrics

userspace/falco/configuration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void falco_configuration::merge_config_files(const std::string &config_name,
211211
}
212212
}
213213

214-
#if !defined(_WIN32) and !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
214+
#if !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
215215
for(auto &filename : m_loaded_configs_filenames) {
216216
m_loaded_configs_filenames_sha256sum.insert(
217217
{filename, falco::utils::calculate_file_sha256sum(filename)});

userspace/falco/falco_metrics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ std::string falco_metrics::falco_to_text_prometheus(
117117
"falco",
118118
{{"version", FALCO_VERSION}});
119119

120-
#if !defined(_WIN32) and !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
120+
#if !defined(MINIMAL_BUILD) and !defined(__EMSCRIPTEN__)
121121
// Note that the rule counter metrics are retrieved from the state, not from any inspector
122122
// Distinguish between config and rules files using labels, following Prometheus best
123123
// practices: https://prometheus.io/docs/practices/naming/#labels

userspace/falco/falco_outputs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ limitations under the License.
2828
#include "outputs_program.h"
2929
#include "outputs_syslog.h"
3030
#endif
31-
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
31+
#if !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
3232
#include "outputs_http.h"
3333
#endif
3434

@@ -93,7 +93,7 @@ void falco_outputs::add_output(const falco::outputs::config &oc) {
9393
oo = std::make_unique<falco::outputs::output_syslog>();
9494
}
9595
#endif
96-
#if !defined(_WIN32) && !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
96+
#if !defined(__EMSCRIPTEN__) && !defined(MINIMAL_BUILD)
9797
else if(oc.name == "http") {
9898
oo = std::make_unique<falco::outputs::output_http>();
9999
}

0 commit comments

Comments
 (0)