mirror of
https://github.com/esphome/esphome.git
synced 2026-09-22 04:28:43 +00:00
Drop the app archive from ldgen_libraries too and add a fragment check
This commit is contained in:
@@ -876,6 +876,9 @@ _LDGEN_CMAKE_STOCK = """\
|
||||
function(__ldgen_create_target exe_target)
|
||||
idf_build_get_property(python PYTHON)
|
||||
|
||||
list(JOIN ldgen_libraries_expr "\\n" ldgen_libraries_str)
|
||||
file(WRITE ${build_dir}/ldgen_libraries.in "${ldgen_libraries_str}")
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${output}
|
||||
COMMAND ${python} "${idf_path}/tools/ldgen/ldgen.py"
|
||||
@@ -899,6 +902,10 @@ def test_patch_ldgen_cmake_inserts_guarded_filter(tmp_path: Path) -> None:
|
||||
_patch_ldgen_cmake(tmp_path)
|
||||
content = ldgen_cmake.read_text(encoding="utf-8")
|
||||
assert _LDGEN_DEP_FILTER in content
|
||||
# The libraries list must be filtered before it is serialized to disk
|
||||
assert content.index("REMOVE_ITEM ldgen_libraries_expr") < content.index(
|
||||
"list(JOIN ldgen_libraries_expr"
|
||||
)
|
||||
assert "DEPENDS ${template}" in content
|
||||
|
||||
|
||||
@@ -931,8 +938,9 @@ def test_patch_ldgen_cmake_unreadable_file_warns_and_skips(
|
||||
id="no_ldgen_deps",
|
||||
),
|
||||
pytest.param(
|
||||
_LDGEN_CMAKE_STOCK + "\n add_custom_command(\n OUTPUT x)\n",
|
||||
id="duplicate_command",
|
||||
_LDGEN_CMAKE_STOCK
|
||||
+ '\n list(JOIN ldgen_libraries_expr "\\n" ldgen_libraries_str)\n',
|
||||
id="duplicate_join",
|
||||
),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -623,6 +623,45 @@ def test_component_cache_ignores_corrupt_file(setup_core: Path, tmp_path: Path)
|
||||
assert toolchain.load_cached_builtin_components() is None
|
||||
|
||||
|
||||
def _write_fragments_build_ninja(tmp_path: Path, fragments: list[Path]) -> None:
|
||||
build_dir = CORE.relative_build_path("build")
|
||||
build_dir.mkdir(parents=True, exist_ok=True)
|
||||
frag_list = ";".join(str(f) for f in fragments)
|
||||
(build_dir / "build.ninja").write_text(
|
||||
f' COMMAND = python ldgen.py --fragments-list "{frag_list}" --input x\n'
|
||||
)
|
||||
|
||||
|
||||
def test_warn_if_app_archive_mapped_warns(
|
||||
setup_core: Path, tmp_path: Path, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""A fragment naming the app archive triggers the loud warning."""
|
||||
_setup_build(setup_core)
|
||||
frag = tmp_path / "linker.lf"
|
||||
frag.write_text("[mapping:evil]\narchive: libsrc.a\nentries:\n * (noflash)\n")
|
||||
_write_fragments_build_ninja(tmp_path, [frag])
|
||||
toolchain._warn_if_app_archive_mapped()
|
||||
assert "maps the app archive" in caplog.text
|
||||
|
||||
|
||||
def test_warn_if_app_archive_mapped_clean(
|
||||
setup_core: Path, tmp_path: Path, caplog: pytest.LogCaptureFixture
|
||||
) -> None:
|
||||
"""Normal fragments produce no warning; missing files are non-fatal."""
|
||||
_setup_build(setup_core)
|
||||
frag = tmp_path / "linker.lf"
|
||||
frag.write_text("[mapping:freertos]\narchive: libfreertos.a\n")
|
||||
_write_fragments_build_ninja(tmp_path, [frag, tmp_path / "missing.lf"])
|
||||
toolchain._warn_if_app_archive_mapped()
|
||||
assert "maps the app archive" not in caplog.text
|
||||
|
||||
|
||||
def test_warn_if_app_archive_mapped_no_build_ninja(setup_core: Path) -> None:
|
||||
"""No build.ninja yet is a quiet no-op."""
|
||||
_setup_build(setup_core)
|
||||
toolchain._warn_if_app_archive_mapped()
|
||||
|
||||
|
||||
def test_run_compile_passes_compile_process_limit(setup_core: Path) -> None:
|
||||
"""compile_process_limit is forwarded to run_idf_py as the job limit."""
|
||||
_setup_build(setup_core)
|
||||
|
||||
Reference in New Issue
Block a user