Harden the pch script for Windows paths and make ignored pchs visible

This commit is contained in:
J. Nick Koston
2026-08-25 15:36:41 -05:00
parent 18eb05177b
commit d08c524f19
7 changed files with 45 additions and 16 deletions
@@ -1766,7 +1766,7 @@ def test_write_project_pch_no_device_path_poison(tmp_path: Path) -> None:
CORE.build_path = tmp_path / name
_set_flags("-DPIO_FRAMEWORK_ARDUINO_LWIP2_HIGHER_BANDWIDTH_LOW_FLASH")
content = _write_ninja(paths, ccache="/usr/bin/ccache")
assert "srccxxflags = -include esphome_pch.h" in content
assert "srccxxflags = -Winvalid-pch -include esphome_pch.h" in content
sums.append(
(CORE.relative_pioenvs_path(name) / "esphome_pch.h.gch.sum").read_text()
)
@@ -97,7 +97,7 @@ def test_pch_script_builds_and_prepends_relative_include(tmp_path: Path) -> None
assert (proj / "esphome_pch.h.gch").is_file()
assert len((proj / "esphome_pch.h.gch.sum").read_text().strip()) == 64
# Relative include: an absolute path would poison ccache keys
assert scons_env.prepended == ["-include", "esphome_pch.h"]
assert scons_env.prepended == ["-Winvalid-pch", "-include", "esphome_pch.h"]
# ccache settings land on the SCons ENV only, never os.environ
assert scons_env["ENV"]["CCACHE_SLOPPINESS"] == "pch_defines,time_macros"
assert scons_env["ENV"]["CCACHE_PCH_EXTSUM"] == "true"