Merge branch 'esp8266-native-build-infra' into esp8266-native-framework-installer

This commit is contained in:
J. Nick Koston
2026-08-22 22:05:04 -05:00
2 changed files with 22 additions and 0 deletions
+15
View File
@@ -645,6 +645,21 @@ def lex_build_flags(entries: str | list[str], owner: str) -> list[str]:
BARE_ARG_FLAGS = frozenset({"-I", "-L", "-l", "-D"})
def raise_on_empty_arg_flags(tokens: list[str], owner: str) -> None:
"""Reject bare ``-I``/``-D``/``-L``/``-l`` tokens left by an empty glued
argument (``-D ""``).
Lives next to ``join_flag_args`` because the bare token is its
postcondition: a trailing bare flag is warned and dropped there, so a
surviving one always means an empty argument. gcc would eat the next
flag as the argument (or add the CWD for ``-L``); always a typo.
"""
if empty := sorted({tok for tok in tokens if tok in BARE_ARG_FLAGS}):
raise EsphomeError(
f"{owner} contain empty-argument flag(s): {', '.join(empty)}"
)
def join_flag_args(tokens: Iterable[str], owner: str) -> list[str]:
"""Join a bare ``-I``/``-L``/``-l``/``-D`` with its following token,
the way PlatformIO's ParseFlags lexes them."""
@@ -656,6 +656,13 @@ def test_prefetch_wave_unknown_size_falls_back_to_sequential(
assert "No Content-Length for https://x/b.tar.gz" in caplog.text
def test_raise_on_empty_arg_flags() -> None:
"""A surviving bare flag means an empty glued argument; reject by name."""
with pytest.raises(EsphomeError, match=r"build_flags contain empty-argument"):
lib.raise_on_empty_arg_flags(["-DFOO", "-D", "-l"], "build_flags")
lib.raise_on_empty_arg_flags(["-DFOO", "-Iinc"], "build_flags")
def test_content_lengths_head_requests(monkeypatch: pytest.MonkeyPatch) -> None:
"""Sizes come from HEAD Content-Length; a failing HEAD reads as 0 so
the combined bar is skipped rather than wrong."""