Skip to content

feat(fqbn): build a vendor core end to end -- core, libraries, sketch, link, images (#1298) - #2251

Merged
zackees merged 2 commits into
mainfrom
agent/1298-fqbn-build
Dec 4, 2026
Merged

zackees merged 2 commits into
mainfrom
agent/1298-fqbn-build

Conversation

@zackees

@zackees zackees commented Dec 4, 2026

Copy link
Copy Markdown
Member

The FQBN path could resolve a board, expand any recipe, compile a unit, archive, link, convert the ELF and flash it — one step per invocation, with the caller carrying every intermediate file. This is the conductor that walks those same steps in Arduino's order and hands each one the output of the one before.

fbuild fqbn arduino:avr:uno --sketch Blink/Blink.ino --build ./out \
  --prop runtime.ide.version=10607

What it does

  • plan_build is data, build is the only spawner — the same split every other step here uses, so the whole composition is testable without a toolchain on any host.
  • Objects mirror their sources under build.path: core/<rel>.o, core/variant/<rel>.o, libraries/<name>/<rel>.o, sketch/<name>.ino.cpp.o plus the sketch's own non-.ino sources (top level and src/).
  • Every recipe still expands {build.path} to the one build root. plan_unit_in carries that root explicitly (a unit living in core/ used to infer its own directory); plan_unit keeps the inferred behaviour, so no existing caller or test changes.
  • Library selection is fqbn_libraries::plan_for_sketch, sketch preprocessing is the shared source_scanner through fqbn_compile, archive/link/pre-link hooks are fqbn_link — no rule is re-derived here.
  • Hook stages run: prebuild, libraries.prebuild, sketch.prebuild, linking.prelink (inside the link), linking.postlink, postbuild, numeric order within a stage. A package that declares a hook in any other stage (core.prebuild, objcopy.*, savehex.*) is refused by key: silently skipping a stage is firmware the vendor did not describe.
  • plan_archive_pending / plan_link_pending exist because a build plans its objects before it compiles them; the single-step planners still require their inputs to exist, so the CLI's --archive/--link keep refusing a missing object.
  • A sketch path must be <dir>/<dir>.ino, and unresolved sketch includes are reported, not refused (the compiler stays the authority over toolchain headers).

Real e2e (no fixtures)

target result
arduino:[email protected] Blink 25 core units → core.a 353,796 B → ELF 14,208 B → .eep 13 B, .hex 2,611 B, exit 0
the same board + real FastLED 3.10.10 via --library-root 38 library units, ELF 61,864 B, .hex 10,126 B, exit 0
Seeeduino:[email protected] xiaonRF52840Plus (the issue's motivating target) 42 core units → core.a 27,637,612 B → ELF 1,732,744 B → .bin 84,632 B, .hex 238,115 B, .zip 85,441 B, exit 0

The mbed run also exercised the package's own pre-link hook (-E -P of the variant linker script into build.path) and its nrfutil packaging recipe; that last step needs the vendor's adafruit-nrfutil on PATH, exactly as the core's own post_install.sh arranges.

Gates

  • engine lib: 752 passed / 0 failed / 6 ignored (10 new tests)
  • cli: 602 passed / 0 failed (4 new tests)
  • clippy -D warnings exit 0; Windows MSVC clippy and macOS aarch64 check exit 0
  • boundary rows=0; dylint_rows=0; research --check exit 0; cargo fmt --check clean
  • RED proven twice: dropping the explicit build.path fails the build-root test; dropping the library include wiring fails the include-dir test

#1298 stays open — this closes the build-driver cell; the issue's surface/open-question list still gets its receipt.

The FQBN path could resolve a board, expand any recipe, compile a unit,
archive, link, convert the ELF and flash it -- one step per invocation,
with the caller carrying every intermediate file. This is the conductor:
`fbuild fqbn <FQBN> --sketch <dir>/<dir>.ino --build <DIR>` walks the
package's own stages in Arduino's order -- core, archive, libraries,
sketch, link, objcopy -- and stops at the first failure naming it.

- new `fqbn_build` (engine): `plan_build` is data (one CompileUnit per
  source, the core archive, the link, the images, the hooks) and `build`
  is the only spawner, so the composition is testable without a toolchain.
- objects mirror their sources under `build.path` (`core/`, `core/variant/`,
  `libraries/<name>/`, `sketch/`); every recipe still expands
  `{build.path}` to the one build root, which `plan_unit_in` now carries
  explicitly (`plan_unit` keeps its inferred form, so no caller changes).
- library selection is `fqbn_libraries::plan_for_sketch`, sketch
  preprocessing is the shared `source_scanner`, archive/link/prelink hooks
  are `fqbn_link` -- no rule is re-derived here.
- hook stages run: prebuild, libraries.prebuild, sketch.prebuild,
  linking.prelink (in the link), linking.postlink, postbuild. A package
  that declares a hook in any other stage is refused by key, because
  silently skipping a stage is firmware the vendor did not describe.
- `plan_archive_pending` / `plan_link_pending` exist because a build plans
  its objects before it compiles them; the single-step planners still
  require their inputs to exist.

Real e2e, no fixtures:
- arduino:[email protected] (installed from the published index) Blink:
  25 core units -> core.a 353,796 B -> ELF 14,208 B -> .eep 13 B, .hex 2,611 B.
- the same AVR board with real FastLED 3.10.10 from a `--library-root`:
  38 library units, ELF 61,864 B, .hex 10,126 B.
- the issue's motivating target, Seeeduino:[email protected]
  `xiaonRF52840Plus`: 42 core units, core.a 27,637,612 B, ELF 1,732,744 B,
  .bin 84,632 B, .hex 238,115 B, and the package's `nrfutil` .zip 85,441 B
  (that last step needs the vendor's pip tool on PATH, as its own
  post_install.sh arranges).

Gates: engine lib 752 passed / 0 failed / 6 ignored (10 new), cli 602
passed / 0 failed (4 new), clippy -D warnings exit 0, Windows MSVC clippy
and macOS aarch64 check exit 0, boundary rows=0; dylint_rows=0, research
--check exit 0, fmt clean. RED twice: dropping the explicit build.path
fails the build-root test, dropping the library include wiring fails the
include-dir test.
…2251)

`dylint / Rust lint` refused `source.as_path().starts_with(variant.as_path())`
in `plan_core_units` (`ban_raw_path_prefix_compare`, #952): a raw prefix
comparison compares components as written, so a canonicalized vs raw spelling
would silently place a variant object under the core tree. `relative_to` is the
workspace's ancestry test and returns the same answer for the same spelling.

Engine 752/0/6 after the change.
@zackees
zackees added this pull request to the merge queue Dec 4, 2026
Merged via the queue into main with commit 0db2944 Dec 4, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant