Skip to content

fix(nxplpc): propagate platformio.ini build_flags to library compile (#587) - #588

Merged
zackees merged 1 commit into
mainfrom
fix/587-nxplpc-lib-build-flags
Jun 14, 2026
Merged

zackees merged 1 commit into
mainfrom
fix/587-nxplpc-lib-build-flags

Conversation

@zackees

@zackees zackees commented Jun 14, 2026 •

Copy link
Copy Markdown
Member

Closes #587.

Summary

  • The nxplpc orchestrator built LibraryBuildEnv with raw compiler.c_flags() / cpp_flags(), so [env:*] build_flags (parsed into ctx.user_flags) only reached the sketch compile path. Library sources reached by lib_extra_dirs never saw -D… defines declared in platformio.ini. That's exactly the gap PR feat(nxplpc): find_core_root + LPC845 RELEASE defines + pin bump to ACLPC#29 #576 worked around by stashing -DRELEASE=1 -DFASTLED_DISABLE_DBG=1 inside lpc845brk.json's extra_flags field (board extra_flags IS applied to libraries; user build_flags were not).
  • This PR mirrors the ESP32 library-compile path: build a LanguageExtraFlags overlay from ctx.user_flags + ctx.global_compile_overlay, then push it through apply_overlay_flags before constructing LibraryBuildEnv.
  • The flag-overlay helpers (apply_user_flags, apply_overlay_flags) moved up from esp32::orchestrator::helpers into crate::flag_overlay (where LanguageExtraFlags lives) so the nxplpc orchestrator can reach them without cross-platform coupling. ESP32 imports updated to the new location; behavior unchanged.
  • With the propagation gap closed, the lpc845brk.json stopgap is no longer needed; chip-id defines stay, the two FastLED-debug defines come out.

Regression fixture

tests/platform/lpc845_build_flags/ with a check_flag probe library that #errors out unless -DFROM_PLATFORMIO_INI=1 from the env's build_flags reaches the library compile path. Driver at crates/fbuild-build/tests/nxplpc_build_flags.rs, #[ignore]d because it downloads the ARM GCC toolchain + vendored ArduinoCore-LPC8xx and performs a real link.

```
soldr cargo test -p fbuild-build --test nxplpc_build_flags -- --ignored
```

Out of scope

Tests run

  • `soldr cargo check --workspace --all-targets` — clean
  • `soldr cargo clippy --workspace --all-targets -- -D warnings` — clean (pre-existing clippy.toml/Cargo.toml MSRV divergence warning only)
  • `soldr cargo fmt --all --check` — clean
  • `bash ./test` — all crate unit tests pass (700 in fbuild-build alone, no regressions)
  • New `flag_overlay` unit tests cover apply_user_flags + the C-vs-CXX scope split
  • `soldr cargo test -p fbuild-build --test nxplpc_build_flags -- --ignored` — gated on hardware-bench follow-up (LPC845-BRK)

Acceptance (from #587)

  • LPC library compile picks up [env:*] build_flags defines — proven by fixture
  • grep -E '\-DRELEASE\|FASTLED_DISABLE_DBG' crates/fbuild-config/assets/boards/json/lpc845brk.json returns no matches
  • LPC845-BRK JSON-RPC sketch links + boots end-to-end with defines sourced from its own platformio.ini — hardware verification still required (LPC845-BRK on bench)
  • PR feat(nxplpc): find_core_root + LPC845 RELEASE defines + pin bump to ACLPC#29 #576 follow-up comment — will post after merge

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes

    • Build flags defined in platformio.ini now properly propagate to library compilation in NXP LPC builds, ensuring libraries receive user-specified compiler defines and options.
  • Tests

    • Added regression test to verify build flags propagate correctly through the library compilation pipeline.

…587)

The nxplpc orchestrator built `LibraryBuildEnv` with raw
`compiler.c_flags()` / `cpp_flags()`, so `[env:*] build_flags` (parsed
into `ctx.user_flags`) only reached the sketch compile — never the
library compile. This is the gap PR #576 worked around by stashing
`-DRELEASE=1 -DFASTLED_DISABLE_DBG=1` inside `lpc845brk.json`'s
`extra_flags` field (board `extra_flags` IS applied to libraries; user
`build_flags` were not).

Mirrors the ESP32 library-compile path: fold `ctx.user_flags` plus the
`global_compile_overlay` into a `LanguageExtraFlags` overlay, then push
it through `apply_overlay_flags` before constructing `LibraryBuildEnv`.

The flag-overlay helpers (`apply_user_flags`, `apply_overlay_flags`)
moved up from `esp32::orchestrator::helpers` into `crate::flag_overlay`
where `LanguageExtraFlags` lives, so the nxplpc orchestrator can reach
them without cross-platform coupling. ESP32 imports updated to the new
location; behavior unchanged.

Regression fixture at `tests/platform/lpc845_build_flags/` with a
probe library that `#error`s out unless `-DFROM_PLATFORMIO_INI=1` from
the env's `build_flags` reaches the library compile path. Driver lives
at `crates/fbuild-build/tests/nxplpc_build_flags.rs`, `#[ignore]`d
because it downloads the ARM GCC toolchain + vendored
ArduinoCore-LPC8xx and performs a real link.

With the propagation gap closed, the `lpc845brk.json` stopgap is no
longer needed; chip-id defines stay, the two FastLED-debug defines come
out. Consuming sketches that want those defines should declare them in
their own `platformio.ini`.

Out of scope: AVR has the identical bug at `avr/orchestrator.rs:262`
and is tracked separately.

Closes #587

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Flag-merging helpers (apply_user_flags, apply_overlay_flags, define_flag_name) are moved from esp32::orchestrator::helpers to crate::flag_overlay. The NXPLPC orchestrator is updated to apply these helpers when building library compile flags, fixing [env:*] build_flags propagation. Stopgap defines are removed from lpc845brk.json and a regression fixture with an integration test is added.

Changes

Build flags propagation fix for NXPLPC library compile

Layer / File(s) Summary
Flag-merge helpers promoted to crate::flag_overlay
crates/fbuild-build/src/flag_overlay.rs, crates/fbuild-build/src/esp32/orchestrator/helpers.rs, crates/fbuild-build/src/esp32/orchestrator/build.rs, crates/fbuild-build/src/esp32/orchestrator/framework_libs.rs, crates/fbuild-build/src/esp32/orchestrator/local_libs.rs, crates/fbuild-build/src/esp32/orchestrator/tests.rs, crates/fbuild-build/src/esp32/orchestrator/README.md
apply_user_flags, apply_overlay_flags, and define_flag_name are added to flag_overlay.rs as pub(crate) with unit tests; the same functions are deleted from esp32::orchestrator::helpers; all ESP32 import sites are updated to reference crate::flag_overlay.
NXPLPC orchestrator: fold user_flags into library compile
crates/fbuild-build/src/nxplpc/orchestrator.rs
Imports apply_overlay_flags and LanguageExtraFlags; constructs a combined user_overlay from ctx.user_flags + ctx.global_compile_overlay; applies it to compiler.c_flags() / compiler.cpp_flags() before constructing LibraryBuildEnv, replacing the previous raw-compiler-flag pass-through.
Regression fixture and integration test
crates/fbuild-config/assets/boards/json/lpc845brk.json, tests/platform/lpc845_build_flags/*, crates/fbuild-build/tests/nxplpc_build_flags.rs
Adds the lpc845_build_flags fixture with platformio.ini injecting -DFROM_PLATFORMIO_INI=1, a probe library (check_flag.cpp) that #errors without it, a sketch exercising the symbol, and an ignored integration test that asserts a successful ELF build; removes the now-redundant -DRELEASE=1 -DFASTLED_DISABLE_DBG=1 stopgap from lpc845brk.json.

Sequence Diagram(s)

sequenceDiagram
  participant platformio.ini
  participant NxpLpcOrchestrator
  participant flag_overlay as crate::flag_overlay
  participant LibraryBuildEnv
  participant check_flag.cpp

  platformio.ini->>NxpLpcOrchestrator: build_flags = -DFROM_PLATFORMIO_INI=1 (via ctx.user_flags)
  NxpLpcOrchestrator->>flag_overlay: apply_user_flags(base_flags, ctx.user_flags)
  flag_overlay-->>NxpLpcOrchestrator: merged flags with -DFROM_PLATFORMIO_INI=1
  NxpLpcOrchestrator->>flag_overlay: apply_overlay_flags(merged_flags, user_overlay, "dummy.c/cpp")
  flag_overlay-->>NxpLpcOrchestrator: final c_flags / cpp_flags
  NxpLpcOrchestrator->>LibraryBuildEnv: construct with final c_flags + cpp_flags
  LibraryBuildEnv->>check_flag.cpp: compile with -DFROM_PLATFORMIO_INI=1
  check_flag.cpp-->>LibraryBuildEnv: compiles successfully (no `#error`)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • #587 (nxplpc: retire #576's board-JSON build_flags workaround) — This PR directly implements all acceptance criteria: folds ctx.user_flags into the NXPLPC library compile via apply_overlay_flags, adds the lpc845_build_flags regression fixture, removes -DRELEASE=1 -DFASTLED_DISABLE_DBG=1 from lpc845brk.json, and adds the ignored integration test.
  • #574 — The refactor moves flag-overlay helpers to a shared crate::flag_overlay module, which is a concrete step toward the unified cross-platform build-flags propagation design described in #574.

Possibly related PRs

  • FastLED/fbuild#42: Both PRs modify crates/fbuild-build/src/flag_overlay.rs and the LanguageExtraFlags type, with this PR adding new functions (apply_user_flags, apply_overlay_flags) that extend the same overlay machinery introduced or modified in #42.

Poem

🐇 Hops the rabbit through the code,
Flags now travel every road —
apply_overlay_flags shared wide,
LPC libs get -D inside.
No more JSON stopgap baked,
The real propagation's awaked! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main fix: propagating platformio.ini build_flags to library compilation in the nxplpc orchestrator, directly addressing issue #587.
Linked Issues check ✅ Passed The PR fully addresses all coding requirements from issue #587: (1) adds user_flags to LPC library compile via apply_overlay_flags, (2) adds regression test fixture with check_flag probe library that errors if FROM_PLATFORMIO_INI is missing, (3) removes the -DRELEASE=1 and -DFASTLED_DISABLE_DBG=1 stopgap from lpc845brk.json, and (4) refactors flag-overlay helpers to shared crate::flag_overlay module.
Out of Scope Changes check ✅ Passed All changes align with issue #587 scope: refactoring flag-overlay helpers is necessary to support the fix, ESP32 import updates are required by the refactoring, and all test/fixture additions directly support the regression proof requirement. No unrelated changes present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/587-nxplpc-lib-build-flags

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
tests/platform/lpc845_build_flags/README.md (1)

24-26: ⚡ Quick win

Add language specifier to fenced code block.

The shell command block should specify bash as the language for proper syntax highlighting and to satisfy the markdown linter.

📝 Proposed fix
-```
+```bash
 soldr cargo test -p fbuild-build --test nxplpc_build_flags -- --ignored

</details>

<details>
<summary>🤖 Prompt for AI Agents</summary>

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

In @tests/platform/lpc845_build_flags/README.md around lines 24 - 26, The fenced
code block containing the shell command "soldr cargo test -p fbuild-build --test
nxplpc_build_flags -- --ignored" is missing a language specifier, which causes
markdown linting to fail and prevents proper syntax highlighting. Add "bash" as
the language identifier to the opening triple backticks by changing ``` to

Source: Linters/SAST tools

🤖 Prompt for all review comments with 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.

Nitpick comments:
In `@tests/platform/lpc845_build_flags/README.md`:
- Around line 24-26: The fenced code block containing the shell command "soldr
cargo test -p fbuild-build --test nxplpc_build_flags -- --ignored" is missing a
language specifier, which causes markdown linting to fail and prevents proper
syntax highlighting. Add "bash" as the language identifier to the opening triple
backticks by changing ``` to ```bash to satisfy the markdown linter and enable
proper syntax highlighting.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 505f8b49-6ba0-4f48-bd7d-2964b27efd5e

📥 Commits

Reviewing files that changed from the base of the PR and between db2a764 and 0863fe0.

📒 Files selected for processing (19)
  • crates/fbuild-build/src/esp32/orchestrator/README.md
  • crates/fbuild-build/src/esp32/orchestrator/build.rs
  • crates/fbuild-build/src/esp32/orchestrator/framework_libs.rs
  • crates/fbuild-build/src/esp32/orchestrator/helpers.rs
  • crates/fbuild-build/src/esp32/orchestrator/local_libs.rs
  • crates/fbuild-build/src/esp32/orchestrator/tests.rs
  • crates/fbuild-build/src/flag_overlay.rs
  • crates/fbuild-build/src/nxplpc/orchestrator.rs
  • crates/fbuild-build/tests/nxplpc_build_flags.rs
  • crates/fbuild-config/assets/boards/json/lpc845brk.json
  • tests/platform/lpc845_build_flags/README.md
  • tests/platform/lpc845_build_flags/libs/README.md
  • tests/platform/lpc845_build_flags/libs/check_flag/README.md
  • tests/platform/lpc845_build_flags/libs/check_flag/library.json
  • tests/platform/lpc845_build_flags/libs/check_flag/src/README.md
  • tests/platform/lpc845_build_flags/libs/check_flag/src/check_flag.cpp
  • tests/platform/lpc845_build_flags/platformio.ini
  • tests/platform/lpc845_build_flags/src/README.md
  • tests/platform/lpc845_build_flags/src/main.ino

@zackees
zackees merged commit 958cb72 into main Jun 14, 2026
88 of 91 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Jun 15, 2026
@zackees
zackees deleted the fix/587-nxplpc-lib-build-flags branch October 16, 2026 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

nxplpc: retire #576's board-JSON build_flags workaround (concrete sub-issue from #574)

1 participant