From 537976a895dea6b3251e9b5fdc9a76f27824f04f Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 28 Aug 2026 16:30:43 -0500 Subject: [PATCH] Keep the flags helper private and make the identity guard explicit --- esphome/build_gen/arduino8266.py | 14 +++++++------- esphome/build_helpers/pch.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/esphome/build_gen/arduino8266.py b/esphome/build_gen/arduino8266.py index 6cb304eb23..ae37402c23 100644 --- a/esphome/build_gen/arduino8266.py +++ b/esphome/build_gen/arduino8266.py @@ -1245,18 +1245,18 @@ def write_project(paths: InstalledPaths, ccache: str | None) -> bool: pch_text = pch_header_text(pch_includes) # The .sum exists only for CCACHE_PCH_EXTSUM; ninja's depfile # handles staleness - checksum = ( - pch_identity( + identity_ok = True + checksum = None + if ccache: + checksum = pch_identity( cxxflags, src_dir, pch_includes, (str(paths.framework), str(paths.toolchain)), ) - if ccache - else None - ) - # Identity unknown under ccache: pch_identity warned and degraded - if not ccache or checksum is not None: + # Identity unknown: pch_identity warned and degraded + identity_ok = checksum is not None + if identity_ok: log_pch_in_use() write_file_if_changed(pch_header, pch_text) sum_path = build_dir / f"{PCH_HEADER_NAME}.gch.sum" diff --git a/esphome/build_helpers/pch.py b/esphome/build_helpers/pch.py index daa1383753..893fd2912d 100644 --- a/esphome/build_helpers/pch.py +++ b/esphome/build_helpers/pch.py @@ -389,7 +389,7 @@ def pch_compile_command( return [*args, "-x", "c++-header", "-c", str(header), "-o", str(gch)], cmd_dir -def flags_identity(tokens: Iterable[str]) -> str: +def _flags_identity(tokens: Iterable[str]) -> str: """Flag string normalized for digest use: strip like ccache's rewriting (user CCACHE_BASEDIR wins); the raw build path covers unresolved (symlinked) spellings.""" @@ -420,7 +420,7 @@ def pch_identity( # The closure is sorted, so root order only enters via the text pch_header_text(include_headers), *extra, - flags_identity(tokens), + _flags_identity(tokens), ), ) except (OSError, UnicodeError) as err: