Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions cmake/plugins_options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Comment on lines +6 to +8

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reapply group changes to cached plugin options

When an existing build directory is reconfigured with a different group value, such as changing FLB_ALL_INPUTS from Inherit to Off, every FLB_IN_* entry is already cached and remains unchanged. As cmake --help-command option documents, 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 👍 / 👎.

option(${option_name} "${description}" ${temp_value})
Comment on lines +6 to 9

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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 -200

Repository: fluent/fluent-bit

Length of output: 32147


Reapply inherited plugin options when group settings change.

option() leaves an existing cache variable unchanged, so switching FLB_ALL_* from On to Off on reconfigure leaves already created plugin options in their previous state. Make explicitly selected plugin overrides persist while updating options still inheriting from the flipped group setting.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmake/plugins_options.cmake` around lines 6 - 9, Update the plugin option
setup around FLB_GROUP_OVERRIDE and option() so inherited options are refreshed
from the current group setting when FLB_ALL_* changes during reconfiguration,
while explicitly selected plugin overrides remain unchanged. Ensure the
cache-backed option is force-updated only for inherited values, preserving the
existing option_name, description, and override behavior.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Apply group settings after Windows defaults

On Windows with the default FLB_WINDOWS_DEFAULTS=On, these new controls do not govern most inputs, outputs, or filters: CMakeLists.txt:441-444 includes cmake/windows-setup.cmake later, whose lines 51-143 unconditionally reset many individual plugin variables. Consequently, for example, a fresh -DFLB_ALL_INPUTS=Off configuration still enables the default Windows inputs, while On still leaves several inputs disabled. Apply the group override after the platform defaults or make those defaults respect the selected group value.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The 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
fi

Repository: 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 200

Repository: fluent/fluent-bit

Length of output: 17621


🌐 Web query:

CMake option command accepts non boolean values option(OFF ON) documentation

💡 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:

CMake STRINGS property cached string does not restrict value set_property CACHE STRING STRINGS documentation

💡 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.

STRINGS only sets GUI choices for CACHE STRING entries; -DFLB_ALL_* can still supply any value. Values that are not exactly Inherit fall through to DEFINE_OPTION(...) and become the initial value for option(), where typos can be interpreted as boolean plugin selection or be handled differently by CMake tooling. Add a check for each FLB_ALL_* against On;Off;Inherit and message(FATAL_ERROR ...) on invalid values.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmake/plugins_options.cmake` around lines 16 - 23, The FLB_ALL_INPUTS,
FLB_ALL_PROCESSORS, FLB_ALL_FILTERS, and FLB_ALL_OUTPUTS cache variables
currently accept arbitrary command-line values. Validate each value immediately
after its cache definition against exactly On, Off, or Inherit, and call
message(FATAL_ERROR ...) for any invalid value before DEFINE_OPTION(...) or
option() processing occurs.

Source: 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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Loading