mirror of
https://github.com/esphome/esphome.git
synced 2026-10-13 17:52:51 +00:00
[core] Fix the native ESP8266 and host builds on Windows without ccache (#20468)
This commit is contained in:
@@ -888,8 +888,9 @@ def test_write_project_plain_asm_rule_skips_preprocessor(tmp_path: Path) -> None
|
||||
_set_flags()
|
||||
content = _write_ninja(paths)
|
||||
assert "lowlevel.s.o: asm " in content
|
||||
assert "rule asm\n command = $cc -x assembler $asflags -c $in -o $out" in content
|
||||
assert "rule asm\n command = $ccache $cc -x assembler $asflags -c $in -o $out" in (
|
||||
content
|
||||
_write_ninja(paths, ccache="/cc/ccache")
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -308,7 +308,10 @@ def test_write_project_pch_skipped_for_a_force_include_in_the_compiler(
|
||||
def test_write_project_without_ccache(tmp_path: Path) -> None:
|
||||
_make_src(tmp_path, "main.cpp")
|
||||
_changed, ninja = _render()
|
||||
assert "ccache = \n" in ninja
|
||||
# No launcher variable, and no leading space on the commands either:
|
||||
# CreateProcess on Windows rejects a command line that starts with one
|
||||
assert "$ccache" not in ninja
|
||||
assert " command = $cxx -MMD -MF $out.d" in ninja
|
||||
|
||||
|
||||
def test_write_project_routes_user_link_flags(tmp_path: Path) -> None:
|
||||
|
||||
@@ -55,3 +55,21 @@ def test_collect_sources_skips_excluded_and_other_files(tmp_path: Path) -> None:
|
||||
tmp_path / "b.cpp",
|
||||
tmp_path / "sub" / "c.S",
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("ccache", ["/usr/bin/ccache", None])
|
||||
def test_compile_rule_lines_splice_the_launcher(ccache: str | None) -> None:
|
||||
"""Without ccache no command keeps a leading space, which CreateProcess
|
||||
on Windows rejects; with it every compile rule starts with the launcher."""
|
||||
commands = [
|
||||
line.removeprefix(" command = ")
|
||||
for line in ninja_gen.compile_rule_lines(ccache)
|
||||
if line.startswith(" command = ")
|
||||
]
|
||||
assert len(commands) == 4
|
||||
for command in commands:
|
||||
if ccache:
|
||||
assert command.startswith("$ccache $c")
|
||||
else:
|
||||
assert command.startswith("$c")
|
||||
assert "$ccache" not in command
|
||||
|
||||
Reference in New Issue
Block a user