Skip to content

feat(fqbn): compile one translation unit through the package's own recipe - #2236

Merged
zackees merged 2 commits into
mainfrom
agent/fqbn-compile-plan
Dec 2, 2026
Merged

zackees merged 2 commits into
mainfrom
agent/fqbn-compile-plan

Conversation

@zackees

@zackees zackees commented Dec 2, 2026

Copy link
Copy Markdown
Member

Follow-up 4b of #1298. #1298 stays open.

What this does

fqbn_recipe (4a) expands a platform.txt recipe into an argv and stops at
data. Something still has to make the decisions the Arduino builder makes
around that command. New engine module fqbn_compile does exactly those, and
nothing else:

  • Which recipe a file needs, from its extension: .c → recipe.c.o.pattern,
    .cpp/.cc/.cxx → recipe.cpp.o.pattern, .S → recipe.S.o.pattern.
    A .ino is refused by naming the stage it lacks — Arduino preprocesses a
    sketch into a .cpp (#include <Arduino.h> plus prototypes) before a recipe
    applies — and an unknown extension is refused listing the ones that are known.
  • Which sources a core has: cores/<build.core> walked recursively and
    sorted (fbuild fqbn <FQBN> --sources).
  • The builder-derived properties, derived from the package tree instead of
    guessed: build.arch (the package architecture, uppercased — Arduino's own
    definition), build.core.path, build.variant.path (only when the board
    declares one), build.path (the object's directory), source_file,
    object_file, and includes — core → variant → source directory → every
    --include, each written -I"<path>" so the recipe grammar's quoting keeps a
    spaced path as one argument.
  • The spawn, through fbuild_core::subprocess (the workspace's single
    funnel), creating the object's directory first. Success is exit 0 and a
    non-empty object.

runtime.ide.version is deliberately not derived: it is the Arduino IDE's
version and fbuild is not that IDE, so it stays a --prop and a recipe naming
it fails naming the reference (the 4a rule, unchanged). Every refusal names what
is wrong and where: missing source, missing --include directory, board without
build.core, declared-but-missing variant directory, and a --prop that
collides with a derived value.

CLI

fbuild fqbn <FQBN> --sources
fbuild fqbn <FQBN> --compile <file> --object <file> [--include DIR]... [--run] [--prop k=v]

--compile prints compile_recipe=, compile_source=, compile_object=,
compile_include.N=, compile_command=; --run adds compile_exit= and
compile_object_bytes= and the process exit code reports the compiler's verdict.
Text stays key=value; --json carries compile{…} / compile_result{…} /
compile_error. A plan failure is in-band (compile_error=) beside the still
successful resolution, like orchestrator_error= / toolchain_error=.

Real evidence (no arduino-cli in the loop)

Both packages are the published ones, installed from their own indexes at the
canonical <data>/packages/<vendor>/{hardware,tools}/ layout:

arduino:[email protected]      --compile cores/arduino/wiring.c
  recipe.c.o.pattern, avr-gcc 7.3.0-atmel3.6.1-arduino7
  includes: cores/arduino, variants/standard
  --run exit 0 -> 10216 B, ELF32 e_machine 83 (Atmel AVR 8-bit)

Seeeduino:[email protected]   --compile cores/arduino/itoa.c
  recipe.c.o.pattern, arm-none-eabi-gcc 7-2017q4
  includes: cores/arduino, variants/SEEED_XIAO_NRF52840_PLUS
  --run exit 0 -> 67396 B, ELF32 e_machine 40 (ARM)

The Seeed run is the one that proves the derivation: that core's recipes name
{build.core.path} / {build.variant.path}, which 4a refused until a caller
passed them by hand.

Gates

  • fqbn_compile module: 13/13 tests.
  • soldr cargo test -p fbuild-build-engine --lib: 684 passed / 0 failed
    (671 before + 13).
  • soldr cargo test -p fbuild-cli --bin fbuild: 578 passed / 0 failed
    (575 + 3: plan rendering, in-band sketch refusal with exit 1, --sources).
  • clippy -D warnings (engine + cli, all targets): 0; fmt: 0.
  • ci/enforce_platform_boundary.py --print-totals → rows=0; dylint_rows=0.
  • cross-target: win-msvc clippy 0, aarch64-darwin check 0.
  • RED proved: making build.arch lowercase instead of uppercased fails
    derives_the_builder_properties_a_recipe_names (exit 101, 1 failed); restored
    to green.

Deliberately not done

  • No linking, no library discovery (recipe.ar.pattern,
    recipe.c.combine.pattern, the libraries/ scan) — this cell stops at the
    object.
  • No sketch preprocessing — a .ino is refused instead of compiled as C++.
  • No recipe.hooks.* execution — still the undecided ruling from 4a.
  • No fbuild build --fqbn wiring — nothing to compile into yet.

…cipe

Follow-up 4b of #1298. `fqbn_recipe` expands a recipe and stops at
data; something has to make the decisions the Arduino builder makes around that
command. `fqbn_compile` does that:

- source extension -> recipe key (.c/.cpp/.cc/.cxx/.S). A `.ino` is refused
  naming the preprocessing stage it needs, and an unknown extension is refused
  listing the ones that are known.
- the core source list: `cores/<build.core>` walked recursively and sorted
  (`fbuild fqbn <FQBN> --sources`).
- the builder-derived properties, derived from the package tree instead of
  guessed: build.arch (architecture uppercased), build.core.path,
  build.variant.path (only when the board declares one), build.path,
  source_file, object_file, includes (core -> variant -> source dir -> --include,
  each written -I"<path>" so the recipe grammar keeps a spaced path intact).
- the spawn, through fbuild_core::subprocess, with the object's directory
  created first; success is exit 0 AND a non-empty object.

`runtime.ide.version` stays a --prop: it is the Arduino IDE's version and fbuild
is not that IDE, so a recipe naming it fails naming the reference. Every
refusal names what is wrong: a missing source, a missing --include directory, a
board without build.core, a declared-but-missing variant directory, a --prop
that collides with a derived value.

Real evidence (both packages installed from their published indexes, no
arduino-cli): arduino:[email protected] -> avr-gcc, recipe.c.o.pattern, 2 include dirs,
spawn exit 0 -> 10216 B ELF32 e_machine 83 (AVR); Seeeduino:[email protected] ->
arm-none-eabi-gcc@7-2017q4, variant SEEED_XIAO_NRF52840_PLUS, spawn exit 0 ->
67396 B ELF32 e_machine 40 (ARM).
@zackees
zackees added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit fba6eb1 Dec 2, 2026
43 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