-
Notifications
You must be signed in to change notification settings - Fork 2k
build: add options for plugins at group granularity #12160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,14 +3,28 @@ macro(DEFINE_OPTION option_name description default_value) | |
| if(FLB_MINIMAL) | ||
| set(temp_value OFF) | ||
| endif() | ||
| if(NOT "${FLB_GROUP_OVERRIDE}" STREQUAL "Inherit") | ||
| set(temp_value ${FLB_GROUP_OVERRIDE}) | ||
| endif() | ||
| option(${option_name} "${description}" ${temp_value}) | ||
|
Comment on lines
+6
to
9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
cat > "$tmp_dir/CMakeLists.txt" <<'EOF'
cmake_minimum_required(VERSION 3.13)
project(cache_probe NONE)
set(FLB_GROUP_OVERRIDE "On")
macro(DEFINE_OPTION option_name description default_value)
set(temp_value "${default_value}")
if(NOT "${FLB_GROUP_OVERRIDE}" STREQUAL "Inherit")
set(temp_value "${FLB_GROUP_OVERRIDE}")
endif()
option("${option_name}" "${description}" "${temp_value}")
endmacro()
DEFINE_OPTION(FLB_TEST_PLUGIN "test" OFF)
message(STATUS "FLB_TEST_PLUGIN=${FLB_TEST_PLUGIN}")
EOF
cmake -S "$tmp_dir" -B "$tmp_dir/build"
cmake -S "$tmp_dir" -B "$tmp_dir/build" -DFLB_GROUP_OVERRIDE=Off
grep -F 'FLB_TEST_PLUGIN=ON' "$tmp_dir/build/CMakeCache.txt"Repository: fluent/fluent-bit Length of output: 199 🏁 Script executed: #!/bin/bash
set -eu
echo "== file =="
wc -l cmake/plugins_options.cmake
sed -n '1,120p' cmake/plugins_options.cmake
echo "== usages =="
rg -n "FLB_GROUP_OVERRIDE|FLB_ALL_|DEFINE_OPTION|option\\(" cmake CMakeLists.txt 2>/dev/null | head -200Repository: fluent/fluent-bit Length of output: 32147 Reapply inherited plugin options when group settings change.
🤖 Prompt for AI Agents |
||
| endmacro() | ||
|
|
||
| # Add the FLB_MINIMAL option | ||
| option(FLB_MINIMAL "Enable minimal build configuration" No) | ||
|
|
||
| # Add options to enable/disable plugins at a group granularity | ||
| set(FLB_ALL_INPUTS "Inherit" CACHE STRING "Enable/Disable all Input plugins (On, Off, Inherit)") | ||
| set(FLB_ALL_PROCESSORS "Inherit" CACHE STRING "Enable/Disable all Processor plugins (On, Off, Inherit)") | ||
| set(FLB_ALL_FILTERS "Inherit" CACHE STRING "Enable/Disable all Filter plugins (On, Off, Inherit)") | ||
| set(FLB_ALL_OUTPUTS "Inherit" CACHE STRING "Enable/Disable all Output plugins (On, Off, Inherit)") | ||
|
Comment on lines
+16
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On Windows with the default AGENTS.md reference: AGENTS.md:L11-L15 Useful? React with 👍 / 👎. |
||
| set_property(CACHE FLB_ALL_INPUTS PROPERTY STRINGS "On;Off;Inherit") | ||
| set_property(CACHE FLB_ALL_PROCESSORS PROPERTY STRINGS "On;Off;Inherit") | ||
| set_property(CACHE FLB_ALL_FILTERS PROPERTY STRINGS "On;Off;Inherit") | ||
| set_property(CACHE FLB_ALL_OUTPUTS PROPERTY STRINGS "On;Off;Inherit") | ||
|
Comment on lines
+16
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -eu
tmp_dir="$(mktemp -d)"
trap 'rm -rf "$tmp_dir"' EXIT
cat > "$tmp_dir/CMakeLists.txt" <<'EOF'
cmake_minimum_required(VERSION 3.13)
project(validation_probe NONE)
set(FLB_ALL_INPUTS "Inherit" CACHE STRING "")
set_property(CACHE FLB_ALL_INPUTS PROPERTY STRINGS "On;Off;Inherit")
if(NOT FLB_ALL_INPUTS IN_LIST _valid_group_values)
set(_valid_group_values On Off Inherit)
endif()
if(NOT FLB_ALL_INPUTS IN_LIST _valid_group_values)
message(FATAL_ERROR "FLB_ALL_INPUTS must be On, Off, or Inherit")
endif()
EOF
if cmake -S "$tmp_dir" -B "$tmp_dir/build" -DFLB_ALL_INPUTS=Typo; then
echo "Expected invalid value to fail" >&2
exit 1
fiRepository: fluent/fluent-bit Length of output: 195 🏁 Script executed: #!/bin/bash
set -eu
printf 'Files matching plugins_options.cmake:\n'
fd -a 'plugins_options\.cmake$' . || true
file="$(fd 'plugins_options\.cmake$' . | head -n 1 || true)"
if [ -n "$file" ]; then
printf '\nOutline:\n'
ast-grep outline "$file" || true
printf '\nFile contents:\n'
cat -n "$file"
fi
printf '\nUsages of FLB_ALL_* override variables:\n'
rg -n 'FLB_ALL_(INPUTS|PROCESSORS|FILTERS|OUTPUTS)|option\($' -S . | head -n 200Repository: fluent/fluent-bit Length of output: 17621 🌐 Web query:
💡 Result: The CMake option command is specifically designed to provide a boolean option for the user to select [1][2]. According to official documentation, its syntax is option( "<help_text>" [value]), where the initial value is treated as a boolean [1][3][4]. While the documentation defines it as a "boolean option," CMake does not strictly enforce this at the command level; the command effectively acts as a shortcut for set( CACHE BOOLEAN "<help_text>") [3]. Because it creates a cache entry with the BOOLEAN type, tools like cmake-gui(1) and ccmake(1) will interpret the value as a boolean and provide a simple toggle interface (ON/OFF) [3][5]. In practice, if you pass a non-boolean value to option, CMake will store it in the cache variable [6]. However, this is generally discouraged because: 1. Logic behavior: If you use the variable in an if statement, CMake will evaluate it using its standard boolean condition rules (e.g., 1, ON, YES, TRUE, Y are true; 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND are false) [6]. 2. User Experience: Tools meant for editing cache entries (like cmake-gui) expect boolean values for variables created with option, and may not handle non-boolean strings in a user-friendly way [3]. If you need a selection mechanism that supports more than two states (like an enum or a list of choices), it is recommended to use the set command with the CACHE STRING option instead of option [3]. For example: set(MY_VAR "ValueA" CACHE STRING "Description") set_property(CACHE MY_VAR PROPERTY STRINGS "ValueA" "ValueB" "ValueC") Citations:
🌐 Web query:
💡 Result: The STRINGS property for a CMake cache entry does not restrict the value of the variable [1][2]. According to the official CMake documentation, the STRINGS property is intended for convenience only [1][3]. Its primary purpose is to inform CMake-based GUI tools (such as cmake-gui or ccmake) that they should provide a selection widget (like a drop-down combo box) containing the enumerated values instead of a generic text entry field [1][4][5]. CMake does not perform any validation to enforce that a cache entry's value matches one of the values listed in its STRINGS property [1][6]. Users can still set the variable to any arbitrary value, for example, by using the command line flag -DVAR=value [4][6]. If you require strict enforcement of allowed values, you must manually implement validation logic within your CMakeLists.txt file [4][6]. A common approach is to check the variable against a list of allowed values and issue a fatal error if the value is invalid [6]: # Example of manual validation set(ALLOWED_VALUES "OptionA" "OptionB") set(MY_VAR "InvalidValue" CACHE STRING "Description") set_property(CACHE MY_VAR PROPERTY STRINGS ${ALLOWED_VALUES}) if(NOT MY_VAR IN_LIST ALLOWED_VALUES) message(FATAL_ERROR "MY_VAR must be one of ${ALLOWED_VALUES}") endif Citations:
Reject invalid group override values before applying them.
🤖 Prompt for AI AgentsSource: Coding guidelines |
||
|
|
||
| # Inputs (sources, data collectors) | ||
| # ================================= | ||
| set(FLB_GROUP_OVERRIDE ${FLB_ALL_INPUTS}) | ||
| DEFINE_OPTION(FLB_IN_BLOB "Enable Blob input plugin" ON) | ||
| DEFINE_OPTION(FLB_IN_CALYPTIA_FLEET "Enable Calyptia Fleet input plugin" ON) | ||
| DEFINE_OPTION(FLB_IN_COLLECTD "Enable Collectd input plugin" ON) | ||
|
|
@@ -70,6 +84,7 @@ DEFINE_OPTION(FLB_IN_EBPF "Enable Linux eBPF input plugin" | |
|
|
||
| # Processors | ||
| # ========== | ||
| set(FLB_GROUP_OVERRIDE ${FLB_ALL_PROCESSORS}) | ||
| DEFINE_OPTION(FLB_PROCESSOR_CONTENT_MODIFIER "Enable content modifier processor" ON) | ||
| DEFINE_OPTION(FLB_PROCESSOR_CUMULATIVE_TO_DELTA "Enable cumulative to delta metrics processor" ON) | ||
| DEFINE_OPTION(FLB_PROCESSOR_LABELS "Enable metrics label manipulation processor" ON) | ||
|
|
@@ -81,6 +96,7 @@ DEFINE_OPTION(FLB_PROCESSOR_TDA "Enable TDA processor" | |
|
|
||
| # Filters | ||
| # ======= | ||
| set(FLB_GROUP_OVERRIDE ${FLB_ALL_FILTERS}) | ||
| DEFINE_OPTION(FLB_FILTER_ALTER_SIZE "Enable alter_size filter" ON) | ||
| DEFINE_OPTION(FLB_FILTER_AWS "Enable aws filter" ON) | ||
| DEFINE_OPTION(FLB_FILTER_CHECKLIST "Enable checklist filter" ON) | ||
|
|
@@ -108,6 +124,7 @@ DEFINE_OPTION(FLB_FILTER_WASM "Enable WASM filter" | |
|
|
||
| # Outputs (destinations) | ||
| # ====================== | ||
| set(FLB_GROUP_OVERRIDE ${FLB_ALL_OUTPUTS}) | ||
| DEFINE_OPTION(FLB_OUT_AZURE "Enable Azure output plugin" ON) | ||
| DEFINE_OPTION(FLB_OUT_AZURE_BLOB "Enable Azure output plugin" ON) | ||
| DEFINE_OPTION(FLB_OUT_AZURE_KUSTO "Enable Azure Kusto output plugin" ON) | ||
|
|
@@ -156,3 +173,5 @@ DEFINE_OPTION(FLB_OUT_TCP "Enable TCP output plugin" | |
| DEFINE_OPTION(FLB_OUT_UDP "Enable UDP output plugin" ON) | ||
| DEFINE_OPTION(FLB_OUT_VIVO_EXPORTER "Enable Vivo exporter output plugin" ON) | ||
| DEFINE_OPTION(FLB_OUT_WEBSOCKET "Enable Websocket output plugin" ON) | ||
|
|
||
| unset(FLB_GROUP_OVERRIDE) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an existing build directory is reconfigured with a different group value, such as changing
FLB_ALL_INPUTSfromInherittoOff, everyFLB_IN_*entry is already cached and remains unchanged. Ascmake --help-command optiondocuments,option()does nothing when its variable is already set, so the override here only affects the first configuration and the new group control silently stops controlling subsequent builds. Propagate group changes to cached plugin options while preserving explicitly supplied individual overrides.Useful? React with 👍 / 👎.