diff --git a/esphome/build_gen/espidf.py b/esphome/build_gen/espidf.py index e26b3a9408..6c52f41810 100644 --- a/esphome/build_gen/espidf.py +++ b/esphome/build_gen/espidf.py @@ -8,6 +8,7 @@ from esphome.build_helpers import pch from esphome.build_helpers.pch import ( PCH_DEFAULT_HEADERS, PCH_HEADER_NAME, + mark_pch_emitted, pch_enabled, pch_header_text, ) @@ -371,6 +372,8 @@ def write_project( CORE.relative_build_path("build", PCH_HEADER_NAME), pch_header_text(PCH_DEFAULT_HEADERS), ) + # Consumers carry the -include; gate the ccache relaxation on it + mark_pch_emitted() # Snapshot the exclusion set so has_outdated_files() can trigger a # discovery reconfigure when it changes. Excluded components never diff --git a/tests/unit_tests/test_espidf_framework.py b/tests/unit_tests/test_espidf_framework.py index cad66a948b..a04b844d3c 100644 --- a/tests/unit_tests/test_espidf_framework.py +++ b/tests/unit_tests/test_espidf_framework.py @@ -19,6 +19,7 @@ from unittest.mock import MagicMock, patch import pytest +from esphome.build_helpers.pch import _PCHData from esphome.espidf.framework import ( ESPHOME_STAMP_FILE, STAMP_SCHEMA_VERSION, @@ -1565,10 +1566,14 @@ def _ccache_patches(tmp_path: Path, which: str | None, build_path: Path | None): "esphome.espidf.framework.get_idf_tools_path", return_value=tmp_path / "tools", ), - # ccache_defaults_env (build_helpers.ccache) reads CORE at call time + # ccache_defaults_env and the pch emission flag read CORE at call time patch( "esphome.core.CORE", - SimpleNamespace(build_path=build_path), + SimpleNamespace( + build_path=build_path, + # Pre-marked: these env tests model a pch-emitting build + data={"pch": _PCHData(emitted=True)}, + ), ), )