#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Check the referee emulators' libretro cores are in place. Until 2026-11-24 each referee was cloned in full at its pinned revision into ``reference/build/`` and built with its own ``Makefile.libretro``. Since then no closed-box source is fetched (Aubrey's rule): the cores built that way stay, their clones moved aside, and a fresh checkout puts shipped cores at the same paths. Genesis Plus GX was https://github.com/ekeeke/Genesis-Plus-GX @ 49c5847648, BlastEm https://github.com/libretro/blastem @ ab743653ed. The cores are driven by ``scripts/libretro_run.py``. - **Genesis Plus GX** (``genesis_plus_gx_libretro.so``): the strongest Sega CD emulation and the most hardware-cited (docs/validation.md). A detector. - **BlastEm** (``blastem_libretro.so``): an independent Sega CD (1.0.0, 2026-09-11) with a CDD microcontroller model on the drive's own clock. A detector. MAME is the system binary (``/usr/games/mame``, 0.285; docs/mame-oracle.md) and is not built here. Needs git, make and a C compiler; no sudo. python scripts/build_referees.py # both python scripts/build_referees.py --only gpgx """ from __future__ import annotations import argparse import json import os import subprocess import sys from pathlib import Path ROOT = Path(__file__).resolve().parents[1] BUILD = ROOT / "reference" / "build" REPOS = {entry["path"].rsplit("/", 1)[1]: entry for entry in json.loads((ROOT / "scripts" / "pinned_repos.json").read_text())} # fmt: skip REFEREES = { "gpgx": ("Genesis-Plus-GX", "genesis_plus_gx_libretro.so"), "blastem": ("blastem", "blastem_libretro.so"), } def clone_full(name: str) -> Path: entry = REPOS[name] path = BUILD / name if path.exists(): head = subprocess.run(["git", "-C", str(path), "rev-parse", "HEAD"], capture_output=True, text=True, check=False).stdout.strip() # fmt: skip if head != entry["rev"]: sys.exit(f"{path} is at {head}, pinned {entry['rev']}: move it aside and rerun") return path path.mkdir(parents=True) git = ["git", "-C", str(path)] subprocess.run([*git, "init", "-q"], check=True) subprocess.run([*git, "remote", "add", "origin", entry["url"]], check=True) subprocess.run([*git, "fetch", "-q", "--depth", "1", "origin", entry["rev"]], check=True) subprocess.run([*git, "checkout", "-q", "FETCH_HEAD"], check=True) print(f"cloned {name} at {entry['rev'][:12]}") return path def build(key: str) -> Path: # Since 2026-11-24 no closed-box source is fetched into this MIT repository (Aubrey's # rule): the cores are programs, the ones built here before that date (their source # clones moved aside) or shipped libretro builds put at the same path. clone_full is # kept for the record and no longer called. name, product = REFEREES[key] core = BUILD / name / product if not core.exists(): sys.exit(f"{core}: put a shipped {product} here (closed-box source is not fetched)") print(f"{key}: {core}") return core def main() -> int: parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) parser.add_argument("--only", choices=sorted(REFEREES), action="append") args = parser.parse_args() for key in args.only or sorted(REFEREES): build(key) return 0 if __name__ == "__main__": sys.exit(main())