fix: publish target lists as the builder resolves them

This commit is contained in:
Abdessamad Derraz committed 2026-10-04 16:55:30 +02:00
1 parent 5691e809c7
commit 97f741bf0f
5 files changed
+103 -14

No files matched your search

+16 -11
View File
@@ -275,19 +275,24 @@ def load_target_config(
raise ValueError(msg)
cores = set(str(c) for c in targets[canonical].get("cores", []))
return apply_target_overrides(cores, overrides, canonical)
default_ovr = overrides.get("_default", {})
ovr = overrides.get(canonical, {})
for c in default_ovr.get("add_cores", []):
cores.add(str(c))
for c in default_ovr.get("remove_cores", []):
cores.discard(str(c))
for c in ovr.get("add_cores", []):
cores.add(str(c))
for c in ovr.get("remove_cores", []):
cores.discard(str(c))
return cores
def apply_target_overrides(
cores: set[str], overrides: dict, target: str
) -> set[str]:
"""Cores of one target once the platform's overrides are applied.
``_default`` applies to every target of the platform, then the target's
own entry: a name the scraper reads as a core on every board (a machine
variant, a launcher) is written once instead of once per board.
"""
result = set(cores)
for scope in ("_default", target):
entry = overrides.get(scope) or {}
result |= {str(c) for c in entry.get("add_cores") or []}
result -= {str(c) for c in entry.get("remove_cores") or []}
return result
def list_available_targets(
+11 -3
View File
@@ -29,6 +29,7 @@ from pathlib import Path
sys.path.insert(0, os.path.dirname(__file__))
from common import (
apply_target_overrides,
artifact_lock,
ArtifactLockBusy,
build_target_cores_cache,
@@ -1896,12 +1897,14 @@ def generate_target_manifests(targets_dir: str, output_dir: str) -> None:
# file instead: the user asked for a filter and got the full pack.
overrides_path = targets_path / "_overrides.yml"
alias_map: dict[str, list[str]] = {}
platform_overrides: dict = {}
if overrides_path.is_file():
with open(overrides_path) as f:
all_overrides = yaml_load(f) or {}
for tname, ovr in (
platform_overrides = (
all_overrides.get(yml_file.stem, {}).get("targets", {}) or {}
).items():
)
for tname, ovr in platform_overrides.items():
names = [a for a in (ovr or {}).get("aliases", []) if isinstance(a, str)]
if names:
alias_map[tname] = names
@@ -1925,7 +1928,12 @@ def generate_target_manifests(targets_dir: str, output_dir: str) -> None:
f"{yml_file}: target {target_name!r} cores must be unique "
"non-empty strings"
)
result[target_name] = cores
# The same add/remove lists the pack builder applies: a list
# published without them makes the installer skip files of a
# core the pack for that target ships.
result[target_name] = sorted(
apply_target_overrides(set(cores), platform_overrides, target_name)
)
for target_name, names in alias_map.items():
if target_name not in result: