mirror of
https://github.com/esphome/esphome.git
synced 2026-09-05 04:26:02 +00:00
Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bc1c91a5f7 | ||
|
|
b81d250737 | ||
|
|
cdd89dbfed | ||
|
|
150f0a3b6c | ||
|
|
4af285a5a0 | ||
|
|
168d96d9f4 | ||
|
|
94fc9ec63a | ||
|
|
e51f711883 | ||
|
|
addcb472af | ||
|
|
b5c78a4711 | ||
|
|
5bc3102c82 | ||
|
|
c4c6fe198e | ||
|
|
41d68d2978 | ||
|
|
7d4e28b5e2 | ||
|
|
8180134d30 | ||
|
|
92b71f8ce4 | ||
|
|
4605ac08a5 | ||
|
|
9580fd14da | ||
|
|
364c530832 | ||
|
|
a0c3a010e4 | ||
|
|
fd871b8898 |
@@ -210,7 +210,7 @@ jobs:
|
||||
- host
|
||||
# Strict by default so a new matrix id cannot silently join in the
|
||||
# degrade-quietly mode the knob exists to catch; the knob is inert
|
||||
# where no pch code runs (esp32-*-platformio, nrf52, host).
|
||||
# where no pch code runs (esp32-*-platformio, nrf52).
|
||||
# Opt-outs: libretiny GCC rejects its own pch until a toolchain bump.
|
||||
include:
|
||||
- id: bk72xx-arduino
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from esphome.build_helpers.pch import pch_enabled, pch_extra_scripts
|
||||
import esphome.codegen as cg
|
||||
import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
@@ -10,7 +11,7 @@ from esphome.const import (
|
||||
ThreadModel,
|
||||
)
|
||||
from esphome.core import CORE
|
||||
from esphome.platformio.toolchain import copy_ccache_script
|
||||
from esphome.platformio.toolchain import copy_ccache_script, copy_pch_script
|
||||
from esphome.types import ConfigType
|
||||
|
||||
from .const import KEY_HOST
|
||||
@@ -18,6 +19,9 @@ from .const import KEY_HOST
|
||||
# force import gpio to register pin schema
|
||||
from .gpio import host_pin_to_code # noqa: F401
|
||||
|
||||
# Guarded wrapper: build_src_flags reaches C/assembly edges too
|
||||
HOST_PCH_PREFIX = "esphome/core/pch_prefix.h"
|
||||
|
||||
CODEOWNERS = ["@esphome/core", "@clydebarrow"]
|
||||
AUTO_LOAD = ["network", "preferences"]
|
||||
IS_TARGET_PLATFORM = True
|
||||
@@ -55,9 +59,18 @@ async def to_code(config: ConfigType) -> None:
|
||||
cg.add_platformio_option("platform", "platformio/native")
|
||||
cg.add_platformio_option("lib_ldf_mode", "off")
|
||||
cg.add_platformio_option("lib_compat_mode", "strict")
|
||||
cg.add_platformio_option("extra_scripts", ["pre:ccache.py"])
|
||||
cg.add_platformio_option("extra_scripts", ["pre:ccache.py", *pch_extra_scripts()])
|
||||
if pch_enabled():
|
||||
# Curated prefix for the pch (the script folds it plus defines.h):
|
||||
# host has no framework force-includes, and the per-TU cost is the
|
||||
# STL closure behind the core headers. Measured -43% compile CPU.
|
||||
# Gated so ESPHOME_PCH_ENABLE=0 restores the strict view. When the
|
||||
# .gch fails to build or load, the force-include stays and every TU
|
||||
# parses the closure as text: correct, but slower than no pch.
|
||||
cg.add_platformio_option("build_src_flags", f"-include {HOST_PCH_PREFIX}")
|
||||
|
||||
|
||||
# Called by writer.py
|
||||
def copy_files() -> None:
|
||||
copy_ccache_script()
|
||||
copy_pch_script()
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
// Curated precompiled-header prefix for backends that force-include it via
|
||||
// build_src_flags (the pch script folds it into the .gch). Guarded because
|
||||
// build_src_flags also reaches C and assembly src edges.
|
||||
#ifdef __cplusplus
|
||||
#include "esphome/core/application.h"
|
||||
#include "esphome/core/automation.h"
|
||||
#endif
|
||||
@@ -247,6 +247,7 @@ def copy_src_tree():
|
||||
Path(
|
||||
"esphome/core/ring_buffer.h"
|
||||
), # moved to components/ring_buffer/, removed in 2026.11.0
|
||||
Path("esphome/core/pch_prefix.h"), # build machinery, not user API
|
||||
}
|
||||
include_l = []
|
||||
for target, _ in source_files_l:
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
"""The host pch prefix must keep resolving; a rename would silently
|
||||
collapse the precompiled set to defines.h with strict CI still green."""
|
||||
|
||||
from pathlib import Path
|
||||
import re
|
||||
|
||||
from esphome.components.host import HOST_PCH_PREFIX
|
||||
|
||||
REPO = Path(__file__).parents[2]
|
||||
|
||||
|
||||
def test_host_pch_prefix_resolves() -> None:
|
||||
prefix = REPO / HOST_PCH_PREFIX
|
||||
assert prefix.is_file()
|
||||
body = prefix.read_text()
|
||||
includes = re.findall(r'#include "([^"]+)"', body)
|
||||
assert includes, "prefix wrapper folds nothing"
|
||||
for name in includes:
|
||||
assert (REPO / name).is_file(), f"{name} does not resolve"
|
||||
# The C guard is what keeps build_src_flags safe on C/assembly edges
|
||||
assert "#ifdef __cplusplus" in body
|
||||
Reference in New Issue
Block a user