Commit Graph
54 Commits
Author SHA1 Message Date
J. Nick Koston 7c47cbdb73 Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission
# Conflicts:
#	esphome/build_gen/arduino8266.py
2026-08-22 15:06:30 -05:00
J. Nick Koston 49dcc89130 Validate the board and flash-ld names; reject valued VTABLES defines; scope the damaged-cache recovery
The board name lands unquoted in two -D bodies and the flash linker
script name joins under the SDK and build ld dirs, so both are now
shape-validated like f_cpu. A VTABLES_IN_* define carrying a body would
split the compile line from the linker script and is refused. The
damaged-cache overwrite moves into a shared _write_generated helper
scoped to the comparison read: a corrupt existing copy is logged and
replaced (the testing-mode flash ld gets the same recovery), while a
genuine write failure still raises with its cause.
2026-08-22 15:05:58 -05:00
J. Nick Koston 10a22d7d74 Quote an overridden ldscript name on the link line; note the deliberate board-derived --flash_size
The -T script name was the one user-controlled token on the link line
that skipped shell_token, so a space or dollar sign in a
board_build.ldscript override corrupted the emitted linkflags. The
elf2bin comment now records that --flash_size deliberately stays
board-derived, matching PlatformIO (which reads upload.maximum_size,
not the ldscript).
2026-08-22 12:02:33 -05:00
J. Nick Koston 905b056756 Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission
# Conflicts:
#	esphome/build_gen/arduino8266.py
2026-08-22 12:01:44 -05:00
J. Nick Koston dc1bbac385 Harden the build spec: content-hashed ld cache, strict f_cpu, loud diagnostics
The linker-script stamp now records the sha256 of the written content, so
an externally edited or truncated cached script regenerates instead of
passing a SECTIONS substring probe, and a non-UTF-8 cached script is
overwritten by the regeneration instead of aborting it. The cached
preprocessor diagnostic re-emit no longer swallows its own read failure.

board_build.f_cpu is validated (digits with an optional L) before landing
unquoted on the compile line, _pio_option rejects empty and blank values
instead of silently reverting to the default, and user MMU define bodies
re-quote through shell_token like every other user token. The plain-form
linker denylist is a named constant the _project_flags docstring points
at, so the two cannot drift.
2026-08-22 12:01:08 -05:00
J. Nick Koston 512a31b3fc Trim comment essays and hoist function-local test imports 2026-08-22 11:44:09 -05:00
J. Nick Koston 3134239d52 Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission 2026-08-22 11:43:02 -05:00
J. Nick Koston 67544598c5 Trim comment essays 2026-08-22 11:42:55 -05:00
J. Nick Koston 91cf9be5eb Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission 2026-08-21 21:11:21 -05:00
J. Nick Koston 2959fb6e7d Resolve the test's gcc path through toolchain_tool so Windows stats the .exe 2026-08-21 21:11:20 -05:00
J. Nick Koston 0973044214 Strip the python path for cmd.exe, name rules by kind, take the resolved install
The build.ninja python variable goes through strip_win_long_path_prefix
like every other emitted binary path (the NSIS launcher's extended
prefix cannot be spawned by cmd.exe). Compile rules are named by the
shared source kinds directly, retiring the identity translation table
and its drift test. write_project takes the caller's resolved ccache,
get_flash_ld_path reads the InstalledPaths the ninja file linked
against instead of re-resolving the version, the board backstop checks
the one table it indexes with an honest comment, and cc/cxx/ar paths go
through the shared toolchain_tool accessor (gaining the Windows
suffix).
2026-08-21 20:49:30 -05:00
J. Nick Koston d628bc3aae Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission
# Conflicts:
#	esphome/build_gen/arduino8266.py
#	tests/unit_tests/build_gen/test_arduino8266.py
2026-08-21 20:47:42 -05:00
J. Nick Koston e5ad855337 Use the shared tool accessor for gcc, drop dead dataclass defaults, add a resolve test helper
toolchain_tool owns the bin path and Windows suffix now; _BuildConfig's
knob and MMU fields are required since the only constructor always
passes both; the tests' set-flags-then-resolve idiom collapses into one
_resolve helper (12 sites).
2026-08-21 20:47:17 -05:00
J. Nick Koston 5474ba2ca1 Honor board_build.ldscript for the native flash linker script
Published configs override it to reserve a filesystem region or correct
a board's assumed flash size; the routed value replaces the BOARDS
default, and a path is rejected since the name resolves via -L.
2026-08-21 20:30:30 -05:00
J. Nick Koston accfd12199 Honor board_build.f_cpu on the native compile line
The routed override (published configs pin 160000000L for
timing-sensitive integrations) reaches -DF_CPU via a small _pio_option
reader; the default stays the audited 80 MHz all 45 boards ship.
2026-08-21 20:28:27 -05:00
J. Nick Koston d78083f9f2 Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission 2026-08-21 20:22:05 -05:00
J. Nick Koston 44b64e0963 Note why F_CPU is hardcoded, widen the plain linker-flag denylist
F_CPU gets the same drift-audit note as _MMU_DEFAULT: upstream reads it
from the board manifest, and all 45 supported boards ship 80000000L.
The plain-form refusal also covers -e, -s, -static, and -nostartfiles,
which gcc accepts inertly on a -c line.
2026-08-21 20:21:57 -05:00
J. Nick Koston 44db267a2c Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission
# Conflicts:
#	esphome/build_gen/arduino8266.py
#	tests/unit_tests/build_gen/test_arduino8266.py
2026-08-21 19:59:54 -05:00
J. Nick Koston df1aa5ff61 Make the lex-once contract structural, stamp the compiler, guard bare -I/-D
tokens is a required parameter on _flag_defines and _project_flags now,
so the per-consumer re-lex the shared lexer was meant to end cannot
come back. The cache stamp covers the gcc binary's size and mtime via
a shared _stat_sig (an in-place toolchain re-extraction regenerates
the script like a header edit). A bare -I or -D from an empty argument
is warned and skipped instead of letting gcc eat the next flag.
_defines_flags documents that its tokens carry shell-level escaping and
must be emitted unquoted, and _MMU_DEFAULT notes why the board-manifest
values are hardcoded.
2026-08-21 19:59:26 -05:00
J. Nick Koston 69f558d83d Pin the board-table equality, note the flash_freq audit
write_project rejects a board missing from either table, so a new test
asserts the two stay exactly equal (the subset check is how d1_wroom_02
went missing). The hardcoded --flash_freq 40 carries the audit note:
all 45 supported boards ship 40 MHz, and a platform bump adding one
that does not must revisit it.
2026-08-21 18:55:52 -05:00
J. Nick Koston 6b56def2bf Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission
# Conflicts:
#	esphome/build_gen/arduino8266.py
#	tests/unit_tests/build_gen/test_arduino8266.py
2026-08-21 18:55:40 -05:00
J. Nick Koston ce5ccb4294 Name every ld-generation failure, refuse inert linker flags, reuse the shared lexer
Both testing-mode segment patches get the RuntimeError-to-EsphomeError
wrap the ratetable surgery already had. Plain-form -T/-Xlinker/-u flags
raise naming the -Wl, form instead of warning into an inert -c compile
line. _lexed_build_flags and _unflag_tokens go through the shared
lex_build_flags so a future lexing fix cannot miss this path. The MMU
conflict message names dropping the variant knob when MMU_CUSTOM is
already set. An unreadable (not absent) header forces a cache miss
every run instead of pinning the stamp to a constant, and preprocessor
warnings persist beside the stamp and re-emit on cache hits. The drift
docstring states what the tests actually pin.
2026-08-21 18:54:19 -05:00
J. Nick Koston 046c7e5eb0 Lex build flags once in write_project, warn on unflags that match nothing
The pre-lexed tokens feed both _flag_defines and _project_flags so a
malformed entry warns once per generation. An unflag that hits nothing
in the user flags or any framework set (a typo, or -DUSE_FOO against
-DUSE_FOO=1) is named instead of silently leaving the flag in force.
2026-08-21 13:33:11 -05:00
J. Nick Koston c0cd64cd76 Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission 2026-08-21 13:32:21 -05:00
J. Nick Koston 7c2254d8ee Refuse knob-plus-raw define splits, lex build flags once, harden the ld cache
A raw MMU_* define alongside a PIO_FRAMEWORK_ARDUINO_MMU_* knob, or a
raw TCP_MSS/LWIP_* alongside the lwIP knobs, would win the compile line
while the linker script or prebuilt library keeps the knob's values;
both now raise like the no-knob case. _MMU_VARIANTS holds tuples and the
resolved config gets a copy, so nothing aliases the module table.
_lexed_build_flags lexes once and both consumers accept the tokens, so
a malformed entry warns once per build. The linker-script stamp covers
the header's size and mtime, an unreadable or non-UTF-8 cache
regenerates instead of aborting, plain-form linker flags warn that they
are not routed to the link line, and a moved rate-table anchor surfaces
as a named build error.
2026-08-21 13:32:12 -05:00
J. Nick Koston 9153f03c83 Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission
# Conflicts:
#	tests/unit_tests/build_gen/test_arduino8266.py
2026-08-21 13:07:03 -05:00
J. Nick Koston 84de74663c Cover the testing-mode flash-ld OSError guard 2026-08-21 13:06:33 -05:00
J. Nick Koston debfff005b Check the elf2bin inputs at generation, quote cxx flags, add d1_wroom_02 to BOARDS
elf2bin.py and eboot.elf join the existence checks so a half-extracted
package fails by name before the compile instead of at the
second-to-last edge. get_project_cxx_compile_flags() values go through
_shell_token like every other flag source. d1_wroom_02 (2 MB, in
ESP8266_BOARD_BUILD and buildable under PlatformIO) joins BOARDS so the
native board guard stops rejecting it, and the guard comment states
what config validation actually checks.
2026-08-21 12:57:36 -05:00
J. Nick Koston 523150a4c9 Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission
# Conflicts:
#	tests/unit_tests/build_gen/test_arduino8266.py
2026-08-21 12:55:51 -05:00
J. Nick Koston 784cf6819f Refuse inconsistent memory-layout configs, validate the cached linker script
Unknown or conflicting VTABLES_IN_* defines raise instead of warning
and picking arbitrarily (a typo previously won the sorted pick and died
in the SDK header's #error). Custom MMU sizes without the CUSTOM knob
raise too: PlatformIO warns but its defaults win the compile line,
while here the user's tokens would win and compile against a layout the
linker script does not implement. The cached linker script is re-checked
for its SECTIONS block so a truncated file regenerates, the
testing-mode flash-ld read gets the same OSError guard as the gcc
spawn, the ParseFlags docstring states its actual coverage, and the ld
test mocks are quiet so the clean path asserts no warnings.
2026-08-21 12:55:23 -05:00
J. Nick Koston afe12061d2 Track the per-platform shell quoting in the emission drift tests
The asm -D/-I filter also strips a leading single quote now that POSIX
tokens are single-quoted.
2026-08-21 12:28:11 -05:00
J. Nick Koston 2d89ca3dd0 Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission
# Conflicts:
#	tests/unit_tests/build_gen/test_arduino8266.py
2026-08-21 12:26:46 -05:00
J. Nick Koston a7febfbf05 Track the per-platform shell quoting in the requote drift test 2026-08-21 12:26:23 -05:00
J. Nick Koston 5a5a379444 Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission
# Conflicts:
#	tests/unit_tests/build_gen/test_arduino8266.py
2026-08-20 23:58:18 -05:00
J. Nick Koston cd2ab6e78b Join unflag tokens, filter knobs by unflags, pin every table verbatim, guard degenerate ld output and empty lib flags 2026-08-20 23:57:45 -05:00
J. Nick Koston fe5325b007 Honor lib_archive, guard unknown boards by name, quote archive names, fix the asm flag filter 2026-08-20 20:42:23 -05:00
J. Nick Koston d342d0a246 Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission 2026-08-20 18:28:28 -05:00
J. Nick Koston e1cbe5e586 Sort flag iteration for reproducible defines, pin the flag tables, wrap a missing compiler cleanly 2026-08-20 18:28:26 -05:00
J. Nick Koston 52aafc3af6 Drop the escaping test superseded by the shared ninja module tests 2026-08-20 16:20:19 -05:00
J. Nick Koston 5c36fefe21 Drop the escaping test duplicated by the shared ninja module tests 2026-08-20 16:15:15 -05:00
J. Nick Koston c3f7ce7a02 Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission
# Conflicts:
#	tests/unit_tests/build_gen/test_arduino8266.py
2026-08-20 16:14:24 -05:00
J. Nick Koston 252422c706 Match ASPPCOM flag routing, quote manifest link tokens, split the src-dir error, pin the change contract 2026-08-20 16:12:28 -05:00
J. Nick Koston 0d794ce678 Lex every build flag entry, warn on custom MMU sizes without the knob, note the scanf omission 2026-08-20 16:10:02 -05:00
J. Nick Koston c629e4a94c Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission
# Conflicts:
#	esphome/build_gen/arduino8266.py
#	tests/unit_tests/build_gen/test_arduino8266.py
2026-08-20 16:07:57 -05:00
J. Nick Koston 0171af9f67 Adopt the shared ninja quoting helpers and typed install paths in the build spec 2026-08-20 16:07:22 -05:00
J. Nick Koston aa4dd3d0a1 Hoist the ninja quoting helpers, type the installed paths, format flash size from board data 2026-08-20 15:48:56 -05:00
J. Nick Koston ea429ffdb6 Derive the suffix rule map, dedupe quoting and unflag filtering, adopt the moved library backend 2026-08-20 15:28:55 -05:00
J. Nick Koston a0d56d02d0 Tighten the emission half: shared srcflags, single escapes, one testing-name derivation 2026-08-20 14:29:54 -05:00
J. Nick Koston 866c59384c Merge branch 'esp8266-native-build-spec' into esp8266-native-ninja-emission 2026-08-20 14:22:05 -05:00
J. Nick Koston cd0c3bb069 Keep the spec half honest: fingerprint-stamped ld cache, MMU table, emission helpers deferred 2026-08-20 14:19:53 -05:00