mirror of
https://github.com/esphome/esphome.git
synced 2026-10-01 17:00:21 +00:00
[espidf] Resolve cmake through the IDF environment when reading the CMake cache (#19947)
This commit is contained in:
@@ -138,7 +138,9 @@ def _get_cmake_output(build_dir) -> str:
|
||||
if not (Path(build_dir) / "CMakeCache.txt").is_file():
|
||||
raise EsphomeError(f"No ESP-IDF build found in {build_dir}")
|
||||
|
||||
cmd = ["cmake", "-LA", "-N", "."]
|
||||
# Resolve to an absolute path: Windows locates a child process
|
||||
# through the parent's PATH, not the env passed to it.
|
||||
cmd = [_get_idf_tool("cmake"), "-LA", "-N", "."]
|
||||
|
||||
env = _get_idf_env()
|
||||
result = subprocess.run(
|
||||
|
||||
@@ -264,6 +264,7 @@ def test_get_cmake_output_with_configured_build(setup_core: Path) -> None:
|
||||
)
|
||||
with (
|
||||
patch.object(toolchain, "_get_idf_env", return_value={}),
|
||||
patch.object(toolchain, "_get_idf_tool", return_value="/idf/tools/cmake"),
|
||||
patch.object(toolchain.subprocess, "run", return_value=completed) as mock_run,
|
||||
):
|
||||
assert toolchain._get_cmake_output(build_dir) == completed.stdout
|
||||
@@ -271,6 +272,9 @@ def test_get_cmake_output_with_configured_build(setup_core: Path) -> None:
|
||||
assert toolchain._get_cmake_output(build_dir) == completed.stdout
|
||||
|
||||
mock_run.assert_called_once()
|
||||
# The resolved path, never a bare "cmake": Windows locates the child
|
||||
# through the parent's PATH, where the IDF-managed cmake is missing.
|
||||
assert mock_run.call_args.args[0][0] == "/idf/tools/cmake"
|
||||
assert toolchain._get_cmake_tool_path("CMAKE_ADDR2LINE") == Path("/tool/addr2line")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user