fix: publish target lists as the builder reads

This commit is contained in:
Abdessamad Derraz committed 2026-10-17 19:16:30 +02:00
1 parent 22eed69f9d
commit c7737d629e
2 files changed
+37 -7

No files matched your search

+8 -7
View File
@@ -33,7 +33,7 @@ from common import (
target_listing_line,
suggest_names,
require_platform,
apply_target_overrides,
load_target_config,
archive_entry,
profiles_for_systems,
write_text_atomic,
@@ -2111,7 +2111,7 @@ def generate_target_manifests(targets_dir: str, output_dir: str) -> None:
if not isinstance(target_info, dict):
raise ValueError(f"{yml_file}: target {target_name!r} must be a mapping")
cores = target_info.get("cores")
if cores is None or cores == []:
if cores is None:
result[target_name] = None
continue
if (
@@ -2123,12 +2123,13 @@ 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"
)
# 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)
# The builder's own reading, overrides included: a list published
# another way makes the installer serve what the pack does not.
# An empty list is a board with no core, not one with every core.
resolved = load_target_config(
yml_file.stem, target_name, str(targets_path.parent)
)
result[target_name] = None if resolved is None else sorted(resolved)
for target_name, names in alias_map.items():
if target_name not in result:
+29
View File
@@ -3161,3 +3161,32 @@ class ASameNamedMemberIsNotTheFile(unittest.TestCase):
self.assertTrue(xr._data_hit(fname, None, held, names))
self.assertFalse(xr._data_hit(fname, None, other, names))
self.assertTrue(xr._data_hit(fname, None, {"name": fname}, names))
class AnEmptyTargetIsNotEveryCore(unittest.TestCase):
"""A board scraped with `cores: []` and `add_cores: [gpsp]`: the pack
served gpsp's files only, the published list said null (every core)."""
def test_the_published_list_is_the_builder_reading(self):
from scripts.common import load_target_config
from scripts.generate_pack import generate_target_manifests
tmp = Path(tempfile.mkdtemp(dir=TMP_ROOT))
self.addCleanup(lambda: __import__("shutil").rmtree(tmp, True))
targets = tmp / "platforms" / "targets"
targets.mkdir(parents=True)
(targets / "demo.yml").write_text(
"platform: demo\ntargets:\n"
" board:\n architecture: aarch64\n cores: []\n"
" full:\n architecture: x86_64\n cores: null\n"
)
(targets / "_overrides.yml").write_text(
"demo:\n targets:\n board:\n add_cores: [gpsp]\n"
)
with contextlib.redirect_stdout(io.StringIO()):
generate_target_manifests(str(targets), str(tmp / "out"))
published = json.loads((tmp / "out" / "demo.json").read_text())
builder = load_target_config("demo", "board", str(tmp / "platforms"))
self.assertEqual(published["board"], sorted(builder))
self.assertEqual(published["board"], ["gpsp"])
self.assertIsNone(published["full"])