mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-23 10:07:48 -06:00
refactor: keep standalone layouts in a file apart
The layouts every list carried grew the download of each run by up to 30% for an option few use. They now live in install/standalone/<platform>.json, written by the same --manifest run and fetched only by a run given --standalone, beside --manifest first. The list names the builds (standalone_builds). A missing, unreachable or invalid file stops --standalone on one line, code 1.
This commit is contained in:
1 parent
03f80eb570
commit
9cb9fec49e
13 files changed
+924
-77
No files matched your search
@@ -2963,6 +2963,7 @@ def _run_manifest_mode(
|
||||
tc = target_cores_cache.get(representative) if args.target else None
|
||||
if _skip_empty_truth(args, source, representative, emu_profiles, tc, failed):
|
||||
continue
|
||||
layouts: dict = {}
|
||||
try:
|
||||
manifest = generate_manifest(
|
||||
representative,
|
||||
@@ -2982,6 +2983,7 @@ def _run_manifest_mode(
|
||||
offline=args.offline,
|
||||
required_only=required_only,
|
||||
no_game_data=getattr(args, "no_game_data", False),
|
||||
standalone_out=layouts,
|
||||
)
|
||||
narrow_suffix = "".join(
|
||||
tag.lower()
|
||||
@@ -3004,6 +3006,9 @@ def _run_manifest_mode(
|
||||
f"{manifest['total_size']} bytes, "
|
||||
f"{manifest['total_omitted']} safely omitted"
|
||||
)
|
||||
for plat in group_platforms if layouts else ():
|
||||
print(f" {_write_standalone_layouts(args.output_dir, plat, layouts)}: "
|
||||
f"{len(layouts)} standalone builds")
|
||||
# Create aliases for grouped platforms (e.g., lakka -> retroarch)
|
||||
for alias_plat in group_platforms:
|
||||
if alias_plat != representative:
|
||||
@@ -4877,6 +4882,7 @@ def generate_manifest(
|
||||
no_game_data: bool = False,
|
||||
one_per_slot: bool = False,
|
||||
known_slot_choices: dict | None = None,
|
||||
standalone_out: dict | None = None,
|
||||
) -> dict:
|
||||
"""Generate a JSON manifest for a platform (same resolution as generate_pack).
|
||||
|
||||
@@ -4887,6 +4893,10 @@ def generate_manifest(
|
||||
A file that is a game's data, not firmware, carries ``"category":
|
||||
"game_data"``, so the installer can leave it out as the builder does
|
||||
under ``no_game_data``. Firmware carries no category.
|
||||
`standalone_out` receives, per emulator with a standalone build, what
|
||||
`--emulator X --standalone` packs (standalone_layouts), which the list
|
||||
itself only names (standalone_builds): written apart, it is fetched
|
||||
only by a run given --standalone.
|
||||
"""
|
||||
config = load_platform_config(platform_name, platforms_dir)
|
||||
if fold_case is not None:
|
||||
@@ -5438,10 +5448,26 @@ def generate_manifest(
|
||||
platforms_dir, repo_root, result,
|
||||
)
|
||||
if layouts:
|
||||
result["standalone_layouts"] = layouts
|
||||
result["standalone_builds"] = sorted(layouts)
|
||||
if standalone_out is not None:
|
||||
standalone_out.update(layouts)
|
||||
return result
|
||||
|
||||
|
||||
STANDALONE_DIR = "standalone"
|
||||
|
||||
|
||||
def _write_standalone_layouts(output_dir: str, platform: str, layouts: dict) -> str:
|
||||
"""install/standalone/<platform>.json, what --standalone reads beside the
|
||||
list. Its [dest, sha1] items take their download from that list."""
|
||||
path = os.path.join(output_dir, STANDALONE_DIR, f"{platform}.json")
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
_write_manifest_if_changed(path, {
|
||||
"schema": 1, "platform": platform, "standalone_layouts": layouts,
|
||||
})
|
||||
return path
|
||||
|
||||
|
||||
def _truth_key(entry: dict) -> tuple:
|
||||
"""What tells one entry from another, as the installer's _entry_key."""
|
||||
root = entry.get("root")
|
||||
|
||||
@@ -1883,6 +1883,15 @@ def _publish_manifests(api: Path) -> list[tuple]:
|
||||
_record(targets / source.name)
|
||||
assets.append((targets / source.name, f"Target list: {source.stem}",
|
||||
"application/json", "schemas/target-manifest.schema.json"))
|
||||
# What install.py --standalone reads beside the list, apart so that no
|
||||
# other run downloads it.
|
||||
standalone = api / "standalone"
|
||||
standalone.mkdir(parents=True, exist_ok=True)
|
||||
for source in sorted((_REPO_ROOT / "install" / "standalone").glob("*.json")):
|
||||
shutil.copy2(source, standalone / source.name)
|
||||
_record(standalone / source.name)
|
||||
assets.append((standalone / source.name, f"Standalone layouts: {source.stem}",
|
||||
"application/json", "schemas/install-standalone.schema.json"))
|
||||
# Every change each updated platform file carries, for a maintainer who
|
||||
# reviews them by script: the Exports page linked only the files.
|
||||
exports = api / "exports"
|
||||
|
||||
@@ -738,6 +738,11 @@ def _semantic_install_checks(path: Path, manifest: dict) -> list[str]:
|
||||
f"{path.relative_to(ROOT)}: entries read below the save directory "
|
||||
"and no save_directory"
|
||||
)
|
||||
builds = ROOT / "install" / "standalone" / path.name
|
||||
if manifest.get("standalone_builds") and path.parent == ROOT / "install" \
|
||||
and not builds.is_file():
|
||||
out.append(f"{path.relative_to(ROOT)}: standalone_builds and no "
|
||||
f"install/standalone/{path.name}")
|
||||
stray = sorted(
|
||||
entry["dest"] for entry in [*files, *omitted]
|
||||
if entry.get("core_folder") and entry.get("root") != "save"
|
||||
@@ -749,6 +754,36 @@ def _semantic_install_checks(path: Path, manifest: dict) -> list[str]:
|
||||
return out
|
||||
|
||||
|
||||
def _semantic_standalone_checks(path: Path, layouts: dict) -> list[str]:
|
||||
"""A standalone layout file goes with its platform's list: the list
|
||||
names the same builds, and each [dest, sha1] item takes its download
|
||||
from a copy of that list."""
|
||||
where = path.relative_to(ROOT)
|
||||
plat = layouts.get("platform")
|
||||
if path.stem != plat:
|
||||
return [f"{where}: platform {plat} in a file named {path.stem}"]
|
||||
listed = ROOT / "install" / f"{plat}.json"
|
||||
if not listed.is_file():
|
||||
return [f"{where}: no install/{plat}.json beside it"]
|
||||
manifest = json.loads(listed.read_text(encoding="utf-8"))
|
||||
out: list[str] = []
|
||||
if sorted(layouts.get("standalone_layouts", {})) != manifest.get("standalone_builds"):
|
||||
out.append(f"{where}: its builds differ from standalone_builds in {listed.name}")
|
||||
held = {
|
||||
copy.get("sha1")
|
||||
for entry in [*manifest.get("files", []), *manifest.get("truth_files", [])]
|
||||
for copy in [entry, *entry.get("alternatives", []), *entry.get("slot_choices", [])]
|
||||
}
|
||||
missing = sorted({
|
||||
item[1] for items in layouts.get("standalone_layouts", {}).values()
|
||||
for item in items if isinstance(item, list) and item[1] not in held
|
||||
})
|
||||
if missing:
|
||||
out.append(f"{where}: {len(missing)} sha1 no copy of {listed.name} carries "
|
||||
f"({missing[0]})")
|
||||
return out
|
||||
|
||||
|
||||
def _event_schema_errors() -> list[str]:
|
||||
"""install-events.schema.json is EVENT_KEYS written out, and a valid schema."""
|
||||
import generate_event_schema # noqa: PLC0415
|
||||
@@ -994,6 +1029,14 @@ def main() -> int:
|
||||
)
|
||||
)
|
||||
|
||||
standalone_paths = sorted((ROOT / "install" / "standalone").glob("*.json"))
|
||||
errors.extend(
|
||||
_validate_json_files(
|
||||
standalone_paths, "install-standalone.schema.json",
|
||||
_semantic_standalone_checks,
|
||||
)
|
||||
)
|
||||
|
||||
target_paths = sorted((ROOT / "install" / "targets").glob("*.json"))
|
||||
errors.extend(
|
||||
_validate_json_files(target_paths, "target-manifest.schema.json")
|
||||
|
||||
Reference in new issue
Block a user