Repository navigation
feat(config): merge [platformio] extra_configs (support multi-file projects) - #1930
Merged
Merged
Conversation
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.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #1929 (
we should support extra configs), following#1928 which refused the key instead of silently ignoring it.
What PlatformIO does
[platformio] extra_configsextends
platformio.iniwith other INI files: shell-style wildcards areallowed, files merge in declaration order, and a later group+option overwrites
an earlier one. An entire
[env:*]section — or justframework,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 insidePlatformIOConfig::from_path_with_overrides, before env resolution, so everycaller (build/deploy/monitor/libraries/clangd/ide/reset) sees the merged view:
platformio.ini, not theprocess cwd;
*,?,[seq],[!seq];literal separators; no leading-dot matches) and are applied in sorted order,
so "later wins" is deterministic rather than directory-order luck;
[env]data still reaches environmentsintroduced 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:
extra_configsplatformio.iniEmpty values, comment-only values, and a same-named key inside
[env:*]remainaccepted (no false red).
Docs:
docs/reference/platformio-ini.mdsection updated from "Refused" to themerge contract;
ini_parser/README.mdlists the new submodule.Tests
New
tests_extra_configs.rs(15 tests) is driven by PlatformIO's own documentedexample: environments declared only in an extra file exist, inherit base
[env]data, and a later extra file's
common.debug_flagsoverride reaches thesubstituted
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):RED proven by two in-place mutations, then restored:
3 passed; 12 failed13 passed; 2 failed(exactly the two wildcard-refusal tests)Other gates:
soldr cargo fmt --checkrc 0,soldr cargo clippy -p fbuild-config --all-targets --no-deps -- -D warningsrc 0,ci/check_test_layout.pyok,ci/enforce_platform_boundary.py --print-totals->rows=44; dylint_rows=43rc 0.python -m ci.run_dylint --package fbuild-configcould not run on this host:soldr dylint preparefell back to building the nightly-2026-08-15 driverlocally 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"tofbuild-config; it was already inCargo.lockat 0.3.3, so the lockfile gains exactly one line and no versionmoves.
🤖 Generated with Hermes Agent