Repository navigation
feat(fqbn): resolve an Arduino FQBN against an installed package (#1298) - #2227
Merged
Merged
Conversation
A PlatformIO board id names a registry row; an FQBN names a package, a version, a board and a set of menu selections. Vendor cores the PlatformIO registry does not carry -- Seeed's Seeeduino:[email protected] is the motivating slice -- therefore cannot be named at all. Add an additive engine module that does the three steps the Arduino builder does, and nothing else: 1. `Fqbn::parse` turns `vendor:architecture:board[:menu=value,...]` into a typed identity. Structural characters and whitespace inside a field are refused (they cannot be escaped in the form), a trailing `:` is an error, and a menu selected twice is refused instead of last-wins. 2. `ArduinoPackage::locate` maps the identity onto `<data_dir>/packages/<vendor>/hardware/<arch>/<version>` and refuses an ambiguous version rather than picking the newest, because an FQBN carries no version and a build must not depend on what happens to be installed. 3. `resolve` reads the package's `boards.txt` (menu selections applied through `arduino_props::load_board_props_with_menu_overrides`, the same helper the PlatformIO path uses) and its `platform.txt` verbatim, and returns the normalized board properties plus `board_config()`. Menu selections are validated against the package first, so an unknown menu or option fails with the available names instead of silently falling back. No index download, no recipe evaluation, no orchestrator choice: recipes keep their `{...}` references and the resolved `mcu` is reported, not interpreted -- `fbuild-build-engine` never references a platform module. Design record, diagnostics table, the measured vertical slice (published Seeeduino:[email protected] archive, SHA-256 65d9de0b..., build.mcu=cortex-m4) and the four follow-ups are in docs/design/fqbn-resolution.md. Gates: fbuild-build-engine lib 624 passed / 0 failed, fqbn module 12/12, clippy -D warnings exit 0, fmt exit 0, boundary rows=0 dylint_rows=0. RED proven twice: removing the menu-validation call fails the bad-selection test, and returning the first installed version fails the ambiguity test.
6 tasks
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.
Resolves the first cell of #1298: parse an Arduino FQBN and resolve it against an installed Arduino data directory. #1298 stays open — the CLI surface, orchestrator mapping, index install and recipe evaluation are the follow-ups listed below (and in the design record).
Why
fbuild build --fqbn Seeeduino:mbed:xiaonRF52840Plusonfbuild 2.5.50:--boardonly accepts ids the bundled database or a project-localboards/<id>.jsondefines, and a vendor core the PlatformIO registry does not carry has neither. That is the exact gap #1298 was filed for, and this PR delivers the additive resolver a CLI flag will call.What landed
crates/fbuild-build-engine/src/fqbn.rs(+fqbn_tests.rs), design recorddocs/design/fqbn-resolution.md:Fqbn::parse—vendor:architecture:board[:menu=value,...]. Structural characters (:,,,=) and whitespace inside any field are refused (they cannot be escaped in the form), a trailing:is an error naming the fix, and a menu selected twice is refused rather than last-wins. Every rejection names the raw input and the offending field.ArduinoPackage::locate— maps the identity onto<data_dir>/packages/<vendor>/hardware/<arch>/<version>(the layoutarduino-cliinstalls). No version is ever guessed: an explicit version must be installed, no version resolves only when exactly one is installed, and several installed versions is an error listing them.resolve— readsboards.txtandplatform.txt(both required; a missing one names the expected path), validates every menu option against the package first — an unknown menu/option lists the available ones — then applies the selections througharduino_props::load_board_props_with_menu_overrides, the same helper the PlatformIO path uses, soboard_build.<menu>and FQBN menus agree by construction.ResolvedFqbn— normalized board properties (mcu,variant,board, …), verbatimplatform.txtproperties (name,version,compiler.*,recipe.*,tools.*with{…}unexpanded), andboard_config()through the existingboards.txtconstructor.Deliberately absent, with reasons in the design record: no index download/install (cache layout + streaming checksum + offline behaviour + trust are their own decision), no recipe evaluation, and no orchestrator choice —
fbuild-build-enginenever references a platform module, so the resolvedmcuis reported, not interpreted.Measured vertical slice (real published package, not a fixture)
Downloaded
https://files.seeedstudio.com/arduino/core/mbed/ArduinoCore-mbed-2.9.3.tar.bz2(34,722,259 bytes, SHA-25665d9de0b77010859dd1ca16bfb36b333ddcfbbd7a93270c431cbf49825fd784f, matches the checksum inpackage_seeeduino_boards_index.json), installed as<data>/packages/Seeeduino/hardware/mbed/2.9.3/, then:The package's
build.mcuiscortex-m4— an ARM core, not a chip — which is why the orchestrator mapping is a follow-up and not a table in this PR.Tests (real output)
soldr cargo test -p fbuild-build-engine --lib→ 624 passed / 0 failed / 6 ignored (existing PlatformIO resolution suites green).soldr cargo test -p fbuild-build-engine --lib fqbn→ 12 passed / 0 failed (parse/round-trip, 8 malformed-FQBN cases, structural chars, resolve, menu overlay + default = first declared option, Uno control, version ambiguity/explicit/absent, absent architecture listing siblings, unknown board listing defined ones, unknown menu/option diagnostics, missing package file,platform.txtproperties).validate_menu_optionscall fails the bad-selection test (11 passed / 1 failed); returning the first installed version in the ambiguity branch fails the version test (11 passed / 1 failed). Both restored +touched → 12/12 green.soldr cargo clippy -p fbuild-build-engine --all-targets -- -D warnings→ exit 0;soldr cargo fmt --check -p fbuild-build-engine→ exit 0;ci/enforce_platform_boundary.py --print-totals→rows=0; dylint_rows=0.Follow-ups (kept on #1298)
--fqbn,board_build.fqbn) throughResolutionContext, with the RED evidence above as its regression test.build.mcuis an ARM core, plus the toolchain mapping now expressed bycompiler.path.platform.txtrecipe evaluation for categories the native orchestrators do not model.