refactor: carry platform launches as a dataclass

standalone_set returned one string set mixing standalone names with ten
JSON-tagged record kinds that every reader re-decoded. platform_launches
now returns a frozen PlatformLaunches (resolve/launches.py) with typed
fields, runs_standalone, is_dual, system_file_index and merged, which
_build_layouts and packprobe share.
This commit is contained in:
Abdessamad Derraz committed 2026-11-24 02:18:53 +01:00
1 parent d3b741e423
commit 6e44a93156
34 files changed
+493 -467

No files matched your search

+7 -6
View File
@@ -17,8 +17,9 @@ from sitegen.guidedata import platform_guides, terminals, install_command
from model.platforms import load_platform_config
from model.registry import list_release_pack_platforms
from model.profiles import reads_own_files
from resolve.layout import data_root_place, runs_standalone
from resolve.standalone import standalone_set
from resolve.launches import PlatformLaunches
from resolve.layout import data_root_place
from resolve.standalone import platform_launches
from resolve.validation import installed_everywhere, installed_with_emulator
from sitegen import markup
from installer_build.module import installer_module
@@ -165,7 +166,7 @@ def emulator_install_route(name: str, profile: dict) -> tuple[str, list[str], tu
# package leaves out the 667 files every other setup's install brings.
if all(installed_with_emulator(f, platform) for f in files):
continue
if standalone and not runs_standalone(name, profile, _standalone_cores(platform)):
if standalone and not _standalone_cores(platform).runs_standalone(name, profile):
continue
if any("--dest" in args for args in platform_args(platform, platform_guides()[platform]).values()):
continue
@@ -194,16 +195,16 @@ def emulator_install_route(name: str, profile: dict) -> tuple[str, list[str], tu
return command, setups, oses
def _standalone_cores(platform: str) -> frozenset[str]:
def _standalone_cores(platform: str) -> PlatformLaunches:
"""The emulators a setup launches as apps, by its platform file."""
inputs = siteinputs.current()
return _standalone_cores_in(str(inputs.platforms), str(inputs.emulators), platform)
@functools.cache
def _standalone_cores_in(platforms_dir: str, emulators_dir: str, platform: str) -> frozenset[str]:
def _standalone_cores_in(platforms_dir: str, emulators_dir: str, platform: str) -> PlatformLaunches:
config = load_platform_config(platform, platforms_dir)
return frozenset(standalone_set(config, profiles_in(emulators_dir, skip_aliases=True)))
return platform_launches(config, profiles_in(emulators_dir, skip_aliases=True))
def install_block(name: str, profile: dict) -> list[str]:
+5 -5
View File
@@ -21,8 +21,8 @@ from collections.abc import Callable, Iterable
from pathlib import Path
from romrecipes import ledger as romrecipes_ledger
from resolve.layout import runs_standalone
from resolve.standalone import standalone_set
from resolve.launches import PlatformLaunches
from resolve.standalone import platform_launches
from model.profiles import unique_emulator_profiles
from packs.crossref import first_hash
from core.hashing import cut_md5_owner, declared_hash_lists, parse_hash_list
@@ -160,7 +160,7 @@ def paired_declarations(files: list, details: list[dict]) -> Iterable[tuple[dict
def _brought_by_readers(
detail: dict, standalone_cores: set[str], platform: str, profiles: dict,
detail: dict, standalone_cores: PlatformLaunches, platform: str, profiles: dict,
) -> bool:
"""Whether every core that reads a platform entry installs it itself.
@@ -179,7 +179,7 @@ def _brought_by_readers(
names = {str(e.get("name")) for e in reader.get("entries") or []}
read = [f for f in profile.get("files") or []
if isinstance(f, dict) and str(f.get("name")) in names]
standalone = runs_standalone(reader["emulator"], profile, standalone_cores)
standalone = standalone_cores.runs_standalone(reader["emulator"], profile)
if filter_files_by_mode(read, standalone):
verdicts.append(not deliverable(read, standalone, platform))
return bool(verdicts) and all(verdicts)
@@ -199,7 +199,7 @@ def wanted_declarations(profiles: dict, coverages: dict, gap_report: dict) -> li
found: list[dict] = []
for key, coverage in sorted(coverages.items()):
systems = coverage.get("config", {}).get("systems") or {}
standalone_cores = standalone_set(coverage.get("config", {}), profiles)
standalone_cores = platform_launches(coverage.get("config", {}), profiles)
by_system: dict[str, list[dict]] = {}
for detail in coverage.get("details", []):
by_system.setdefault(detail.get("system", ""), []).append(detail)