Repository navigation
feat(fqbn): compile one translation unit through the package's own recipe - #2236
Merged
Merged
Conversation
…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).
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.
Follow-up 4b of #1298. #1298 stays open.
What this does
fqbn_recipe(4a) expands aplatform.txtrecipe into anargvand stops atdata. Something still has to make the decisions the Arduino builder makes
around that command. New engine module
fqbn_compiledoes exactly those, andnothing else:
.c→recipe.c.o.pattern,.cpp/.cc/.cxx→recipe.cpp.o.pattern,.S→recipe.S.o.pattern.A
.inois refused by naming the stage it lacks — Arduino preprocesses asketch into a
.cpp(#include <Arduino.h>plus prototypes) before a recipeapplies — and an unknown extension is refused listing the ones that are known.
cores/<build.core>walked recursively andsorted (
fbuild fqbn <FQBN> --sources).guessed:
build.arch(the package architecture, uppercased — Arduino's owndefinition),
build.core.path,build.variant.path(only when the boarddeclares one),
build.path(the object's directory),source_file,object_file, andincludes— core → variant → source directory → every--include, each written-I"<path>"so the recipe grammar's quoting keeps aspaced path as one argument.
fbuild_core::subprocess(the workspace's singlefunnel), creating the object's directory first. Success is exit 0 and a
non-empty object.
runtime.ide.versionis deliberately not derived: it is the Arduino IDE'sversion and fbuild is not that IDE, so it stays a
--propand a recipe namingit fails naming the reference (the 4a rule, unchanged). Every refusal names what
is wrong and where: missing source, missing
--includedirectory, board withoutbuild.core, declared-but-missing variant directory, and a--propthatcollides with a derived value.
CLI
--compileprintscompile_recipe=,compile_source=,compile_object=,compile_include.N=,compile_command=;--runaddscompile_exit=andcompile_object_bytes=and the process exit code reports the compiler's verdict.Text stays
key=value;--jsoncarriescompile{…}/compile_result{…}/compile_error. A plan failure is in-band (compile_error=) beside the stillsuccessful 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: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 callerpassed them by hand.
Gates
fqbn_compilemodule: 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).-D warnings(engine + cli, all targets): 0; fmt: 0.ci/enforce_platform_boundary.py --print-totals→rows=0; dylint_rows=0.check0.build.archlowercase instead of uppercased failsderives_the_builder_properties_a_recipe_names(exit 101, 1 failed); restoredto green.
Deliberately not done
recipe.ar.pattern,recipe.c.combine.pattern, thelibraries/scan) — this cell stops at theobject.
.inois refused instead of compiled as C++.recipe.hooks.*execution — still the undecided ruling from 4a.fbuild build --fqbnwiring — nothing to compile into yet.