Skip to content

feat(config): merge [platformio] extra_configs (support multi-file projects) - #1930

Merged
zackees merged 2 commits into
mainfrom
agent/extra-configs-support
Nov 6, 2026
Merged

zackees merged 2 commits into
mainfrom
agent/extra-configs-support

Conversation

@zackees

@zackees zackees commented Nov 6, 2026

Copy link
Copy Markdown
Member

Implements #1929 (we should support extra configs), following
#1928 which refused the key instead of silently ignoring it.

What PlatformIO does

[platformio] extra_configs
extends platformio.ini with other INI files: shell-style wildcards are
allowed, files merge in declaration order, and a later group+option overwrites
an earlier one. An entire [env:*] section — or just framework, board,
build_flags — can therefore live outside the base file.

What this PR does

crates/fbuild-config/src/ini_parser/extra_configs.rs (new) runs inside
PlatformIOConfig::from_path_with_overrides, before env resolution, so every
caller (build/deploy/monitor/libraries/clangd/ide/reset) sees the merged view:

  • entries resolve against the directory holding platformio.ini, not the
    process cwd;
  • wildcards expand with Python-glob semantics (*, ?, [seq], [!seq];
    literal separators; no leading-dot matches) and are applied in sorted order,
    so "later wins" is deterministic rather than directory-order luck;
  • merging is per section+key, so base [env] data still reaches environments
    introduced by an extra file, and ${...} substitution runs after the merge
    (a ${common.debug_flags} override in an extra file is visible).

Refused rather than approximated, because PlatformIO fails or silently drops
these:

Case Why
listed file missing PlatformIO rejects the project too
wildcard matching no file expanding to nothing would build from a subset
extra file declaring extra_configs PlatformIO merges the option but never re-processes it
list resolving back to platformio.ini self-include

Empty values, comment-only values, and a same-named key inside [env:*] remain
accepted (no false red).

Docs: docs/reference/platformio-ini.md section updated from "Refused" to the
merge contract; ini_parser/README.md lists the new submodule.

Tests

New tests_extra_configs.rs (15 tests) is driven by PlatformIO's own documented
example: environments declared only in an extra file exist, inherit base [env]
data, and a later extra file's common.debug_flags override reaches the
substituted build_flags. Plus wildcard ordering, comma/multiline lists,
relative-to-ini resolution, and all four refusal paths.

Real output (soldr cargo test -p fbuild-config --lib):

test result: ok. 249 passed; 0 failed; 1 ignored      (was 240 passed -> +15 new, -6 replaced)

RED proven by two in-place mutations, then restored:

  • merge call removed -> 3 passed; 12 failed
  • empty-wildcard error disabled -> 13 passed; 2 failed (exactly the two wildcard-refusal tests)

Other gates: soldr cargo fmt --check rc 0, soldr cargo clippy -p fbuild-config --all-targets --no-deps -- -D warnings rc 0, ci/check_test_layout.py ok,
ci/enforce_platform_boundary.py --print-totals -> rows=44; dylint_rows=43 rc 0.

python -m ci.run_dylint --package fbuild-config could not run on this host:
soldr dylint prepare fell back to building the nightly-2026-08-15 driver
locally and that build fails with pre-existing E0514 found crate ... compiled by an incompatible version of rustc / E0428 name main defined multiple times
(the broker is a different soldr image generation). Environment issue, not this
diff; CI's Dylint jobs are the authority.

Dependency note: adds glob = "0.3" to fbuild-config; it was already in
Cargo.lock at 0.3.3, so the lockfile gains exactly one line and no version
moves.

🤖 Generated with Hermes Agent

PlatformIO extends platformio.ini with the files listed in
`[platformio] extra_configs`: shell-style wildcards are allowed, files merge
in declaration order, and a later group+option overwrites an earlier one.
fbuild refused the key (#1928) because reading only the base
file would build from a subset of what the project declares; this implements
the option instead (#1929).

`ini_parser/extra_configs.rs` resolves each entry against the directory
holding platformio.ini (not the cwd), expands wildcards with Python-glob
semantics (literal separators, no leading-dot matches) and merges the parsed
sections over the base before env resolution, so inheritance, base `[env]`
data and `${...}` substitution all see the merged view.

The cases PlatformIO would silently lose are refused, not approximated: a
listed file that does not exist, a wildcard matching no file, an extra file
that declares extra_configs again (PlatformIO merges the option but never
re-processes it), and a list that resolves back to platformio.ini itself.

Tests follow PlatformIO's own documented example, including an env that only
exist in an extra file inheriting base `[env]` data and a later file
overriding an earlier one.
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

The Dylint jobs rejected the first revision of extra_configs.rs:

  error: use fbuild_core::path::NormalizedPath instead of std::path::PathBuf
  error: raw `canonicalize` leaks the Windows `\\?\` extended-length prefix
         into cache keys and logs.

Resolve the listed files to display strings instead of `PathBuf` values, and
decide "is this the base file?" with `fbuild_core::path::normalize_for_key`
(a filesystem-free, platform-stable key) rather than `std::fs::canonicalize`.
Merging a file into itself is only a no-op in the best case, so the refusal
stays -- it no longer needs a filesystem round-trip to fire.
@zackees
zackees added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit cb3693c Nov 6, 2026
30 checks passed
@zackees
zackees deleted the agent/extra-configs-support branch November 6, 2026 07:57
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 7, 2026
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.

1 participant