mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 15:27:33 +00:00
Demote invalid-pch on PlatformIO too, pin the compile locale, document the .sum invariant
This commit is contained in:
@@ -1271,6 +1271,9 @@ def write_project(paths: InstalledPaths, ccache: str | None) -> bool:
|
||||
)
|
||||
write_file_if_changed(pch_header, pch_text)
|
||||
if checksum is not None:
|
||||
# Valid only for a ninja run started by write_project: a
|
||||
# direct ninja invocation can rebuild the .gch via its
|
||||
# depfile while this generate-time .sum lags behind
|
||||
write_file_if_changed(
|
||||
build_dir / f"{PCH_HEADER_NAME}.gch.sum", checksum + "\n"
|
||||
)
|
||||
|
||||
@@ -95,6 +95,8 @@ def _compile_gch(cxx, flags, header: Path, gch: Path, proj_dir: Path):
|
||||
result = subprocess.run( # noqa: PLW1510
|
||||
[cxx, "-x", "c++-header", *flags, "-c", str(header), "-o", str(gch)],
|
||||
cwd=proj_dir,
|
||||
# C locale keeps diagnostics matchable by _TRANSIENT_ERRORS
|
||||
env={**os.environ, "LC_ALL": "C"},
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
@@ -318,7 +320,11 @@ def _setup_pch() -> None:
|
||||
# entries: GCC only uses a .gch while no other tokens have been seen.
|
||||
# The relative name also reaches "pio run -t idedata" output; external
|
||||
# consumers replaying cxx_flags must run from the project dir.
|
||||
projenv.Prepend(CXXFLAGS=["-Winvalid-pch", "-include", header.name]) # noqa: F821
|
||||
projenv.Prepend( # noqa: F821
|
||||
# -Wno-error: the probe is per-process, so a later cc1plus can still
|
||||
# reject the .gch; that must stay a warning under user -Werror
|
||||
CXXFLAGS=["-Winvalid-pch", "-Wno-error=invalid-pch", "-include", header.name]
|
||||
)
|
||||
print("ESPHome: Compiling with precompiled header")
|
||||
|
||||
|
||||
|
||||
@@ -156,7 +156,12 @@ 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 == ["-Winvalid-pch", "-include", "esphome_pch.h"]
|
||||
assert scons_env.prepended == [
|
||||
"-Winvalid-pch",
|
||||
"-Wno-error=invalid-pch",
|
||||
"-include",
|
||||
"esphome_pch.h",
|
||||
]
|
||||
# In production projenv["ENV"] aliases os.environ; only the -include
|
||||
# flags are genuinely scoped to projenv (src compiles)
|
||||
assert scons_env["ENV"]["CCACHE_SLOPPINESS"] == "pch_defines,time_macros"
|
||||
|
||||
Reference in New Issue
Block a user