Check install completeness before spawning the linker-script gcc

A half-extracted framework cache now names the missing path instead of
surfacing a gcc failure; pure reorder, the checks depend on nothing
the generation step produces.
This commit is contained in:
J. Nick Koston
2026-09-23 23:13:03 +01:00
parent 1f94d0e904
commit c54e671a26
2 changed files with 13 additions and 9 deletions
+11 -9
View File
@@ -932,23 +932,16 @@ def write_project(paths: InstalledPaths, ccache: str | None) -> bool:
raise EsphomeError(f"Invalid flash mode {flash_mode!r}")
flash_ld_name = _flash_ld_name(board)
generate_ld_scripts(paths, config, flash_ld_name)
sdk = framework / "tools" / "sdk"
core_dir = framework / "cores" / "esp8266"
variant_dir = framework / "variants" / board_build["variant"]
src_dir = CORE.relative_src_path()
libraries = resolve_libraries(
framework,
pio_platform="espressif8266",
board_mcu="esp8266",
cache_key="arduino8266",
)
if not src_dir.is_dir():
# Generated project state, not install state: clean-all would not help
raise EsphomeError(f"Generated source directory {src_dir} is missing")
# Completeness checks run before generate_ld_scripts spawns gcc so a
# half-extracted install names the missing path, not a gcc error.
# A missing install directory would otherwise surface as a wall of
# include errors; failing here names the path instead.
include_dirs = [
@@ -974,6 +967,15 @@ def write_project(paths: InstalledPaths, ccache: str | None) -> bool:
raise EsphomeError(
f"{_INCOMPLETE_INSTALL}: missing {required_file}; {_CLEAN_HINT}"
)
generate_ld_scripts(paths, config, flash_ld_name)
libraries = resolve_libraries(
framework,
pio_platform="espressif8266",
board_mcu="esp8266",
cache_key="arduino8266",
)
for lib in libraries:
include_dirs += lib.include_dirs
@@ -1709,5 +1709,7 @@ def test_write_project_rejects_spaced_ldscript_override(tmp_path: Path) -> None:
CORE.platformio_options = {"board_build.ldscript": "my script.ld"}
paths = _make_framework(tmp_path)
_set_flags()
# The completeness checks run first; give them a src dir to pass
CORE.relative_src_path().mkdir(parents=True, exist_ok=True)
with pytest.raises(EsphomeError, match="Invalid flash linker script name"):
arduino8266.write_project(paths, None)