mirror of
https://github.com/esphome/esphome.git
synced 2026-09-11 15:27:33 +00:00
Merge branch 'platformio-pch-rp2' into platformio-pch-libretiny
This commit is contained in:
@@ -203,16 +203,21 @@ def pch_compile_command(
|
||||
e
|
||||
for e in entries
|
||||
if isinstance(e, dict)
|
||||
and e.get("file", "").replace("\\", "/").startswith(src_prefix)
|
||||
and e.get("file", "").endswith(CXX_SOURCE_SUFFIXES)
|
||||
and isinstance(e.get("file"), str)
|
||||
and e["file"].replace("\\", "/").startswith(src_prefix)
|
||||
and e["file"].endswith(CXX_SOURCE_SUFFIXES)
|
||||
),
|
||||
None,
|
||||
)
|
||||
if entry is None:
|
||||
_LOGGER.warning("No src C++ entry in the compile database, skipping pch")
|
||||
return None
|
||||
cmd_dir = Path(entry.get("directory") or build_dir)
|
||||
tokens = expand_response_files(split_command(entry.get("command", "")), cmd_dir)
|
||||
directory = entry.get("directory")
|
||||
cmd_dir = Path(directory) if isinstance(directory, str) and directory else build_dir
|
||||
command = entry.get("command")
|
||||
tokens = expand_response_files(
|
||||
split_command(command if isinstance(command, str) else ""), cmd_dir
|
||||
)
|
||||
# A DB recorded with ccache enabled prefixes the compiler with the
|
||||
# launcher; the .gch must be compiled directly
|
||||
if tokens and is_launcher(tokens[0]):
|
||||
|
||||
@@ -690,6 +690,17 @@ def test_pch_compile_command_rejects_unusable_entries(tmp_path: Path) -> None:
|
||||
_, cmd_dir = pch_compile_command(build, header, gch)
|
||||
assert cmd_dir == build
|
||||
|
||||
# Corrupted entries with null fields must skip, not raise
|
||||
db.write_text(
|
||||
json.dumps(
|
||||
[
|
||||
{"file": None, "command": "g++ -c x.cpp", "directory": None},
|
||||
{"file": src_file, "command": None, "directory": None},
|
||||
]
|
||||
)
|
||||
)
|
||||
assert pch_compile_command(build, header, gch) is None
|
||||
|
||||
# arguments-style entry (allowed by the spec, unused by CMake)
|
||||
db.write_text(
|
||||
json.dumps([{"arguments": ["g++", "-c", src_file], "file": src_file}])
|
||||
|
||||
Reference in New Issue
Block a user