diff --git a/esphome/build_helpers/pch.py b/esphome/build_helpers/pch.py index 112bf2d2eb..7141b39aba 100644 --- a/esphome/build_helpers/pch.py +++ b/esphome/build_helpers/pch.py @@ -212,18 +212,6 @@ _PCH_STRIP_FLAGS_WITH_ARG = frozenset({"-o", "-c", "-MT", "-MF", "-MQ"}) _PCH_STRIP_FLAGS = frozenset({"-MD", "-MMD", "-MP", "-MM", "-M"}) -def _db_source_path(entry: dict, build_dir: Path) -> Path: - """A compile database entry's source file as a resolved absolute path.""" - path = Path(entry["file"]) - if not path.is_absolute(): - directory = entry.get("directory") - base = ( - Path(directory) if isinstance(directory, str) and directory else build_dir - ) - path = base / path - return path.resolve() - - def pch_compile_command( build_dir: Path, header: Path, gch: Path ) -> tuple[list[str], Path] | None: @@ -254,7 +242,7 @@ def pch_compile_command( if isinstance(e, dict) and isinstance(e.get("file"), str) and e["file"].endswith(CXX_SOURCE_SUFFIXES) - and _db_source_path(e, build_dir).is_relative_to(src_root) + and Path(e["file"]).resolve().is_relative_to(src_root) ), None, )