Skip to content

feat(fqbn): expand a resolved FQBN's build recipe into an argv (#1298) - #2235

Merged
zackees merged 1 commit into
mainfrom
agent/fqbn-uno-control
Dec 2, 2026
Merged

zackees merged 1 commit into
mainfrom
agent/fqbn-uno-control

Conversation

@zackees

@zackees zackees commented Dec 2, 2026

Copy link
Copy Markdown
Member

What this adds

fbuild fqbn <FQBN> --recipe <key> --prop k=v — expand one platform.txt build
recipe for a resolved board into the command it names, and print it without
executing it. This is the expansion half of #1298's follow-up 4 (the design
doc's new "Follow-up 4a" section); fbuild build --fqbn stays the remaining
cell.

fbuild fqbn arduino:avr:uno --recipe recipe.c.o.pattern \
  --prop build.arch=AVR --prop runtime.ide.version=10607 --prop includes= \
  --prop source_file=./Blink.c --prop object_file=./Blink.o
recipe=recipe.c.o.pattern
command="…/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-gcc" -c -g -Os -w -std=gnu11 … -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10607 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR  "./Blink.c" -o "./Blink.o"

--json adds recipe{key, template, command, argv[]}; argv is the shell-free
split. A recipe that cannot expand is reported in-band as recipe_error= beside
a successful resolution, like orchestrator_error=/toolchain_error=.

Three rules, all refusals

  • Nothing is invented. The property set is platform.txt + the board record
    • what the caller passes. Values the Arduino builder derives itself
      (build.arch, runtime.ide.version, build.core.path, build.variant.path,
      source_file, object_file, includes, build.path) are caller properties
      when a recipe names them; an unset one is an error naming the reference.
      Deriving build.arch from a Platform would be the second mcu → Platform
      rule this work already refused to add.
  • A --prop never overrides the package — it is refused naming both sides,
    because a silent override compiles for a different target.
  • Quoting is " only; a backslash stays literal ("-IC:\Arduino\libraries"
    survives). An unterminated quote is refused, not guessed.

A real defect found by the real recipes

The pre-existing {…} expander budgeted expansion passes and replaced exactly
one reference per pass, so any template naming more than 8 references was
reported as a {…} cycle. Every earlier template had two references; the real
recipe.c.o.pattern names thirteen. A pass now expands every reference at its
level, so the bound counts nesting — which is what a cycle is. Proved RED by
restoring the one-reference-per-pass loop: does not finish expanding after 8 passes (a {…} cycle …), test exit 101.

Measured, on published packages (no arduino-cli anywhere)

arduino:[email protected]     (official index)  -> … avr-gcc, 15 argv
  spawn exit 0 -> Blink.o, ELF32 "Machine: Atmel AVR 8-bit microcontroller"
Seeeduino:[email protected]  (Seeed index)     -> … arm-none-eabi-gcc, 26 argv
  spawn exit 0 -> Blink.o, ELF32 "Machine: ARM"

The AVR run is also the acceptance control for "not Seeed-specific": second
vendor, second architecture (avr), second tool family (.tar.bz2 avr-gcc),
and a uno record with no menus at all. The Seeed run refuses
{build.core.path}/{build.variant.path} until they are passed — the honest
refusal, verified.

Gates (all real output)

  • fqbn_recipe 8/8; engine --lib 671 passed, 0 failed (59 fqbn*);
    fbuild-cli --bin fbuild 575 passed, 0 failed (26 fqbn*, 4 new).
  • cargo fmt --all -- --check clean; clippy -p fbuild-build-engine -p fbuild-cli --all-targets -- -D warnings exit 0; cross-target
    x86_64-pc-windows-msvc clippy exit 0 and aarch64-apple-darwin check exit 0
    (ci-full-only lints).
  • ci/enforce_platform_boundary.py --print-totals → rows=0; dylint_rows=0.
  • RED twice: one-reference-per-pass loop → AVR recipe test fails (exit 101);
    collision guard disabled → shadowing test fails (exit 101).

Deliberately not done

  • Nothing executes the expanded command; no source list, no {includes}
    contents, no recipe.hooks.* (executed, not expanded — still undecided).
  • No build --fqbn wiring, and no change to the PlatformIO resolution path.

Docs: docs/reference/cli.md (fbuild fqbn section + summary row) and
docs/design/fqbn-resolution.md ("Follow-up 4a", follow-up list item 4).
#1298 stays open.

Adds `fqbn_recipe::expand_recipe` and `fbuild fqbn --recipe <key> --prop k=v`:
one platform.txt recipe (e.g. recipe.c.o.pattern) is expanded for the resolved
board into the command it names, exposed as text and as a shell-free argv, with
nothing executed.

Rules: nothing unset is invented (builder-derived values such as build.arch,
runtime.ide.version, build.core.path, source_file are caller properties);
a --prop never overrides a boards.txt/platform.txt property; quoting is `"`
only so a backslash stays literal.

Fixes the pre-existing {..} expander, which budgeted expansion passes and
replaced one reference per pass, so any template naming more than 8 references
was misreported as a cycle. A pass now expands every reference at its level.

Measured on arduino:[email protected] and Seeeduino:[email protected] installed from their
published indexes: both expanded recipes spawned an ELF32 object (Atmel AVR /
ARM) with no hand-written flags.
@zackees
zackees added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit af7ed70 Dec 2, 2026
44 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Dec 2, 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