Merge branch 'esp8266-native-pch' into esp32-idf-pch

This commit is contained in:
J. Nick Koston
2026-08-26 10:01:27 -05:00
5 changed files with 48 additions and 3 deletions
@@ -386,6 +386,10 @@ def test_write_project_pch(tmp_path: Path) -> None:
'#include "esphome/core/defines.h"',
]
assert (build_dir / "esphome_pch.h.gch.sum").read_text().strip()
# Emission recorded so the framework env exports the ccache settings
from esphome.build_helpers.pch import ccache_pch_env
assert "CCACHE_PCH_EXTSUM" in ccache_pch_env()
def test_write_project_pch_sum_only_with_ccache(tmp_path: Path) -> None:
@@ -456,6 +460,10 @@ def test_write_project_pch_skipped_when_user_force_include_precedes(
assert "esphome_pch" not in content
assert "srccxxflags" not in content
assert "prevents the precompiled header" in caplog.text
# No pch emitted: the ccache relaxation must stay off
from esphome.build_helpers.pch import ccache_pch_env
assert ccache_pch_env() == {}
def test_write_project_pch_disabled(
@@ -33,7 +33,14 @@ def test_pch_enabled(value: str | None, expected: bool) -> None:
assert pch.pch_enabled() is expected
def test_ccache_pch_env_empty_until_emitted() -> None:
"""No sloppiness relaxation for a build that skipped the pch."""
with patch.dict(os.environ, {}, clear=True):
assert pch.ccache_pch_env() == {}
def test_ccache_pch_env_enabled() -> None:
pch.mark_pch_emitted()
with patch.dict(os.environ, {}, clear=True):
env = pch.ccache_pch_env()
assert env["CCACHE_SLOPPINESS"] == "pch_defines,time_macros"
@@ -48,6 +55,7 @@ def test_ccache_pch_env_disabled() -> None:
def test_ccache_pch_env_token_check_is_membership_not_substring(
caplog: pytest.LogCaptureFixture,
) -> None:
pch.mark_pch_emitted()
"""A token merely containing ours must not suppress the union."""
with patch.dict(os.environ, {"CCACHE_SLOPPINESS": "pch_defines_extra"}, clear=True):
env = pch.ccache_pch_env()
@@ -57,6 +65,7 @@ def test_ccache_pch_env_token_check_is_membership_not_substring(
def test_ccache_pch_env_unions_user_sloppiness(
caplog: pytest.LogCaptureFixture,
) -> None:
pch.mark_pch_emitted()
"""Without pch_defines/time_macros ccache declines every pch-consuming
compile, so missing tokens are unioned onto the user's value."""
with patch.dict(os.environ, {"CCACHE_SLOPPINESS": "locale"}, clear=True):
@@ -9,6 +9,7 @@ from unittest.mock import MagicMock, patch
import pytest
from esphome.arduino8266 import framework, toolchain
from esphome.build_helpers.pch import mark_pch_emitted
import esphome.config_validation as cv
from esphome.const import (
CONF_COMPILE_PROCESS_LIMIT,
@@ -632,6 +633,7 @@ def test_get_idedata_accepts_preresolved_ccache() -> None:
def test_ccache_env_includes_pch_settings() -> None:
mark_pch_emitted()
"""The native build exports the ccache settings the pch needs."""
with patch.dict(os.environ, {}, clear=True):
env = framework.ccache_env("/usr/bin/ccache")
@@ -647,6 +649,7 @@ def test_ccache_env_pch_disabled() -> None:
def test_ccache_env_respects_user_sloppiness() -> None:
mark_pch_emitted()
with patch.dict(os.environ, {"CCACHE_SLOPPINESS": "locale"}, clear=True):
env = framework.ccache_env("/usr/bin/ccache")
# The user's tokens survive; the ones the pch needs are unioned on