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
4 changes: 3 additions & 1 deletion platformio/builder/tools/piobuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ def ProcessProjectDeps(env):
env.Exit(1)

if "test" not in env["BUILD_TYPE"] or env.GetProjectOption("test_build_src"):
plb.env.BuildSources(
src_env = plb.env.Clone()
src_env.ProcessFlags(src_env.get("BUILD_SRC_FLAGS"))
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

build_src_flags is stored in the build env as SRC_BUILD_FLAGS (see platformio/project/options.py), but this code reads BUILD_SRC_FLAGS, so the option won’t be applied to project sources (and builds that rely on -D… in build_src_flags will break). Use SRC_BUILD_FLAGS here.

Suggested change
src_env.ProcessFlags(src_env.get("BUILD_SRC_FLAGS"))
src_env.ProcessFlags(src_env.get("SRC_BUILD_FLAGS"))

Copilot uses AI. Check for mistakes.
Comment on lines +179 to +180
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

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

If this is changed to use SRC_BUILD_FLAGS, note that ProjectAsLibBuilder already processes SRC_BUILD_FLAGS into plb.env during initialization (via ProjectAsLibBuilder.build_flags + LibBuilderBase.process_extra_options). Processing the same flags again on src_env would duplicate them. To truly scope build_src_flags to project source compilation, SRC_BUILD_FLAGS should be removed/avoided from plb.env and applied only on the dedicated env used to compile $PROJECT_SRC_DIR.

Suggested change
src_env = plb.env.Clone()
src_env.ProcessFlags(src_env.get("BUILD_SRC_FLAGS"))
# Use a dedicated environment for project sources to avoid
# re-processing source build flags that may already be applied in plb.env
src_env = env.Clone()
build_src_flags = plb.env.get("BUILD_SRC_FLAGS") or env.get("BUILD_SRC_FLAGS")
if build_src_flags:
src_env.ProcessFlags(build_src_flags)

Copilot uses AI. Check for mistakes.
src_env.BuildSources(
"$BUILD_SRC_DIR", "$PROJECT_SRC_DIR", env.get("SRC_FILTER")
)

Expand Down
Loading