#!/usr/bin/env python3 # SPDX-License-Identifier: MIT """Have emu-tools-gpl build the referee drivers, which live outside this repository. Since 2026-11-25 (decisions page T3) both detectors' sources, drivers and builds are in emu-tools-gpl (``EMU_TOOLS_GPL`` names a checkout of it; docs/provenance.md), and this script only runs their build scripts as separate programs (emu-tools docs/contract.md, section 5): - mGBA: ``$EMU_TOOLS_GPL/tools/mgba/build.py --machine gba`` builds Lua 5.4.7, mGBA's core (``libmgba.a`` with ``mgba-headless``: headless, Lua scripting, no Qt, SDL, OpenGL or FFmpeg) and our ``mgba_driver``, at ``$EMU_TOOLS_GPL/tools/mgba/build/gba/mgba_driver``, which scripts/referee_run.py drives. Until then all three were built here under ``reference/build/`` from ``scripts/mgba_driver.c`` (now in that tool). - With ``--nba``, NanoBoyAdvance: ``$EMU_TOOLS_GPL/tools/nanoboyadvance/build.py --machine gba`` builds our ``nba_driver`` at ``$EMU_TOOLS_GPL/tools/nanoboyadvance/build/gba/nba_driver`` (``reference/build/nba/nba_driver`` before). Nintendo's BIOS is not needed to build anything; the runs take the BIOS from the path the user gives (docs/handoff-brief.md, owner's decisions). Exit status 3, naming the variable, without ``EMU_TOOLS_GPL``. python scripts/build_referees.py # mGBA python scripts/build_referees.py --nba # also NanoBoyAdvance """ from __future__ import annotations import argparse import os import subprocess import sys from pathlib import Path #: Each tool's build script and program, at their fixed paths under EMU_TOOLS_GPL. TOOLS = { "mGBA": ("tools/mgba/build.py", "tools/mgba/build/gba/mgba_driver"), "NanoBoyAdvance": ( "tools/nanoboyadvance/build.py", "tools/nanoboyadvance/build/gba/nba_driver", ), } def build(name: str) -> Path: """Run the tool's ``build.py --machine gba``; its program's path, or exit with its status.""" script, program = TOOLS[name] root = os.environ.get("EMU_TOOLS_GPL") if not root or not (Path(root) / script).exists(): print(f"{name}: set EMU_TOOLS_GPL (the build is $EMU_TOOLS_GPL/{script})") sys.exit(3) command = [sys.executable, "-I", str(Path(root) / script), "--machine", "gba"] done = subprocess.run(command, check=False) if done.returncode: sys.exit(done.returncode) return Path(root) / program def main() -> int: parser = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) parser.add_argument("--nba", action="store_true", help="also build NanoBoyAdvance's driver") args = parser.parse_args() print("mGBA driver:", build("mGBA")) if args.nba: print("NanoBoyAdvance:", build("NanoBoyAdvance")) return 0 if __name__ == "__main__": sys.exit(main())