Merge branch 'esp8266-native-ninja-emission' into esp8266-arduino-toolchain

This commit is contained in:
J. Nick Koston
2026-08-22 14:21:11 -05:00
3 changed files with 28 additions and 11 deletions
+10 -5
View File
@@ -331,11 +331,14 @@ def resolve_libraries(
# macOS/Windows and build the bundled Wire twice); the safety guard
# stays fused with the lookup (path traversal)
libraries_dir = framework_path / "libraries"
bundled_dir_names = (
frozenset(p.name for p in libraries_dir.iterdir() if p.is_dir())
if libraries_dir.is_dir()
else frozenset()
if not libraries_dir.is_dir():
# Falling back to the registry would fail later with a misleading
# package-not-found error for every bundled name
raise EsphomeError(
f"{libraries_dir} is missing; the framework install may be "
"incomplete (run 'esphome clean-all')"
)
bundled_dir_names = frozenset(p.name for p in libraries_dir.iterdir() if p.is_dir())
def _provided(name: object) -> bool:
return _is_safe_library_name(name) and name in bundled_dir_names
@@ -404,7 +407,9 @@ def resolve_libraries(
# via the converter, and the walk reports any real drops
continue
try:
check_library_data(dep, pio_platform, "arduino")
# framework=None: the walk already warned for a frameworks
# mismatch; re-checking would warn twice
check_library_data(dep, pio_platform, None)
except InvalidLibrary as err:
# The shared walk already reported any non-platform cause;
# warning again here would read as two distinct failures
+4 -3
View File
@@ -429,7 +429,7 @@ def split_list_by_condition(
return matched, non_matched
def check_library_data(data: dict, platform: str | None, framework: str):
def check_library_data(data: dict, platform: str | None, framework: str | None):
"""
Check whether a library manifest is compatible with the target toolchain.
@@ -446,7 +446,8 @@ def check_library_data(data: dict, platform: str | None, framework: str):
for targets (e.g. Zephyr) where PIO manifests rarely declare the
platform yet portable libraries still build.
framework: The active framework name (e.g. ``espidf``, ``arduino``,
``zephyr``) the manifest is expected to declare.
``zephyr``) the manifest is expected to declare. ``None`` skips
the framework check (and its warning), mirroring ``platform``.
Raises:
InvalidLibrary: If the library does not support the target platform.
@@ -472,7 +473,7 @@ def check_library_data(data: dict, platform: str | None, framework: str):
# under the target framework, and there's no way to opt out of the check at
# this layer. Warn instead of failing so the user isn't forced to fork the
# library to fix the manifest.
valid_framework = "*" in frameworks or framework in frameworks
valid_framework = framework is None or "*" in frameworks or framework in frameworks
if not valid_framework:
_LOGGER.warning(
+13 -2
View File
@@ -458,6 +458,16 @@ def test_nonplatform_rejection_warns_once_through_real_converter(
assert caplog.text.count("manifest is corrupt") == 1
def test_missing_libraries_dir_is_a_broken_install(tmp_path: Path) -> None:
"""A framework tree without libraries/ must fail by name, not silently
reroute every bundled name to the registry."""
framework = tmp_path / "framework"
framework.mkdir()
_add_library("Wire", None)
with pytest.raises(EsphomeError, match="framework install may be incomplete"):
_resolve(framework)
def test_provided_is_case_sensitive(tmp_path: Path) -> None:
"""Membership uses the exact on-disk names, so a case-insensitive
filesystem cannot add the same bundled library twice."""
@@ -595,12 +605,13 @@ def test_bundled_dependency_platform_rejection_is_debug(
with (
_emitting_converter(converted),
patch.object(
pio_library,
component,
"check_library_data",
side_effect=IncompatiblePlatform("nothing about the p-word here"),
),
):
_resolve(framework)
libs = _resolve(framework)
assert "Wire" not in [lib.name for lib in libs]
assert "Skipping dependency Wire" not in caplog.text