mirror of
https://github.com/esphome/esphome.git
synced 2026-08-27 08:28:30 +00:00
Escape object paths once at the source and drop a dead parameter
This commit is contained in:
@@ -80,7 +80,7 @@ def run_compile(config: ConfigType, verbose: bool) -> int:
|
||||
# regeneration (a ninja spawn plus MBs of text) on unchanged builds.
|
||||
if ninja_changed or not (build_dir / "compile_commands.json").is_file():
|
||||
_write_compile_commands(paths["ninja_path"], build_dir, env)
|
||||
_print_size_summary(build_dir, paths["toolchain_path"])
|
||||
_print_size_summary(build_dir)
|
||||
get_idedata()
|
||||
return 0
|
||||
|
||||
@@ -125,7 +125,7 @@ def _parse_app_size(build_dir: Path) -> int | None:
|
||||
return app_size
|
||||
|
||||
|
||||
def _print_size_summary(build_dir: Path, toolchain_path: Path) -> None:
|
||||
def _print_size_summary(build_dir: Path) -> None:
|
||||
"""Print the PlatformIO-shaped RAM/Flash lines.
|
||||
|
||||
The exact shape (including the bar) is parsed by
|
||||
|
||||
@@ -410,7 +410,9 @@ def _ninja_compile_edges(
|
||||
lines.append(f"build {_e(obj)}: {_RULE_FOR_SUFFIX[src.suffix]} {_e(src)}")
|
||||
if flags:
|
||||
lines.append(f" flags = {flags}")
|
||||
objects.append(obj)
|
||||
# Escaped once here: the returned paths only ever appear in build
|
||||
# statements (archive/link inputs), which use ninja escaping.
|
||||
objects.append(_e(obj))
|
||||
return objects
|
||||
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ def test_print_size_summary(tmp_path: Path, capsys: pytest.CaptureFixture[str])
|
||||
),
|
||||
patch.object(toolchain, "_parse_app_size", return_value=1044464),
|
||||
):
|
||||
toolchain._print_size_summary(tmp_path, tmp_path / "toolchain")
|
||||
toolchain._print_size_summary(tmp_path)
|
||||
out = capsys.readouterr().out
|
||||
# Exact PlatformIO shape so script/ci_memory_impact_extract.py can parse it
|
||||
assert "RAM: [==== ] 37.9% (used 31016 bytes from 81920 bytes)" in out
|
||||
@@ -167,7 +167,7 @@ def test_print_size_summary_no_app_size(
|
||||
),
|
||||
patch.object(toolchain, "_parse_app_size", return_value=None),
|
||||
):
|
||||
toolchain._print_size_summary(tmp_path, tmp_path / "toolchain")
|
||||
toolchain._print_size_summary(tmp_path)
|
||||
out = capsys.readouterr().out
|
||||
assert "RAM:" in out
|
||||
assert "Flash:" not in out
|
||||
@@ -183,7 +183,7 @@ def test_print_size_summary_size_tool_failure(
|
||||
"run",
|
||||
return_value=MagicMock(returncode=1, stdout="", stderr="bad elf"),
|
||||
):
|
||||
toolchain._print_size_summary(tmp_path, tmp_path / "toolchain")
|
||||
toolchain._print_size_summary(tmp_path)
|
||||
assert capsys.readouterr().out == ""
|
||||
assert "Could not summarize firmware size" in caplog.text
|
||||
|
||||
@@ -239,7 +239,7 @@ def test_print_size_summary_unparsable_section(
|
||||
"run",
|
||||
return_value=MagicMock(returncode=0, stdout=bad),
|
||||
):
|
||||
toolchain._print_size_summary(tmp_path, tmp_path / "toolchain")
|
||||
toolchain._print_size_summary(tmp_path)
|
||||
assert capsys.readouterr().out == ""
|
||||
assert "Unparsable size output" in caplog.text
|
||||
|
||||
@@ -253,7 +253,7 @@ def test_print_size_summary_unparsable_section(
|
||||
),
|
||||
patch.object(toolchain, "_parse_app_size", return_value=1044464),
|
||||
):
|
||||
toolchain._print_size_summary(tmp_path, tmp_path / "toolchain")
|
||||
toolchain._print_size_summary(tmp_path)
|
||||
assert "RAM:" in capsys.readouterr().out
|
||||
assert "Unparsable size output" in caplog.text
|
||||
|
||||
@@ -272,6 +272,6 @@ def test_print_size_summary_missing_section_skips_summary(
|
||||
"run",
|
||||
return_value=MagicMock(returncode=0, stdout=without_bss),
|
||||
):
|
||||
toolchain._print_size_summary(tmp_path, tmp_path / "toolchain")
|
||||
toolchain._print_size_summary(tmp_path)
|
||||
assert capsys.readouterr().out == ""
|
||||
assert "missing section(s) .bss" in caplog.text
|
||||
|
||||
Reference in New Issue
Block a user