From 29e2e13d65a148103dba9869c1b04290118ca4ab Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 6 Oct 2026 12:47:50 +0200 Subject: [PATCH] fix: cross-reference the build a platform runs --- scripts/cross_reference.py | 21 ++++++++++++++++---- tests/test_standalone_mode.py | 36 +++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/scripts/cross_reference.py b/scripts/cross_reference.py index e8e23f5e..0374b4e5 100644 --- a/scripts/cross_reference.py +++ b/scripts/cross_reference.py @@ -29,6 +29,7 @@ from common import ( name_match_size_ok, parse_md5_list, require_yaml, + runs_standalone, ) yaml = require_yaml() @@ -254,6 +255,7 @@ def _cross_reference_profile( declared: dict[str, set[str]], report: dict, index: dict, + standalone_cores: set[str] | None = None, ) -> None: """Compare one emulator profile against what the platforms declare. @@ -281,6 +283,9 @@ def _cross_reference_profile( for sys_id in systems: platform_names.update(declared.get(_norm_system_id(sys_id), set())) + # The build a platform runs decides which entries it reads, as in + # find_undeclared_files: without a platform, the libretro build. + is_standalone = runs_standalone(emu_name, profile, standalone_cores or set()) gaps = [] covered = [] unsourceable_list: list[dict] = [] @@ -320,9 +325,11 @@ def _cross_reference_profile( if "path" in f and f["path"] is None: continue - # Skip standalone-only files + # Skip the entries of the build the platform does not run file_mode = f.get("mode", "both") - if file_mode == "standalone": + if file_mode == "standalone" and not is_standalone: + continue + if file_mode == "libretro" and is_standalone: continue # Skip files loaded from non-system directories (save_dir, content_dir) @@ -438,6 +445,7 @@ def cross_reference( platform_data_dirs: dict[str, set[str]] | None = None, data_names: set[str] | None = None, all_declared: set[str] | None = None, + standalone_cores: set[str] | None = None, ) -> dict: """Compare emulator profiles against platform declarations. @@ -477,7 +485,7 @@ def cross_reference( } for emu_name, profile in profiles.items(): _cross_reference_profile( - emu_name, profile, declared, report, index + emu_name, profile, declared, report, index, standalone_cores ) return report @@ -554,6 +562,7 @@ def main(): if args.target and not args.platform: parser.error("--target requires --platform") + standalone_cores: set[str] = set() if args.platform: from common import load_target_config, resolve_platform_cores @@ -565,6 +574,7 @@ def main(): config = load_platform_config(args.platform, args.platforms_dir) relevant = resolve_platform_cores(config, profiles, target_cores=target_cores) profiles = {k: v for k, v in profiles.items() if k in relevant} + standalone_cores = {str(c) for c in config.get("standalone_cores", [])} if not profiles: print("No emulator profiles found.", file=sys.stderr) @@ -575,7 +585,10 @@ def main(): ) db = load_database(args.db) data_names = _build_supplemental_index() - report = cross_reference(profiles, declared, db, plat_data_dirs, data_names) + report = cross_reference( + profiles, declared, db, plat_data_dirs, data_names, + standalone_cores=standalone_cores, + ) if args.json: print(json.dumps(report, indent=2)) diff --git a/tests/test_standalone_mode.py b/tests/test_standalone_mode.py index b7dc5b84..2de43020 100644 --- a/tests/test_standalone_mode.py +++ b/tests/test_standalone_mode.py @@ -18,6 +18,18 @@ import yaml REPO_ROOT = Path(__file__).resolve().parent.parent +DUAL_PROFILE = { + "emulator": "Dual", + "type": "standalone + libretro", + "cores": ["dual"], + "systems": ["sys"], + "files": [ + {"name": "both.bin"}, + {"name": "standalone.bin", "mode": "standalone"}, + {"name": "libretro.bin", "mode": "libretro"}, + ], +} + class StandaloneProfilesCarryNoFileMode(unittest.TestCase): def test_every_profile_follows_it(self): @@ -55,5 +67,29 @@ class StandaloneProfilesCarryNoFileMode(unittest.TestCase): ) +class CrossReferenceReadsTheBuildThePlatformRuns(unittest.TestCase): + """cross_reference dropped every standalone entry whatever the platform: + for Recalbox, which runs Dolphin standalone, it reported 12 Dolphin gaps + where verify and the pack builder found 26.""" + + def _gaps(self, standalone_cores): + import sys + + sys.path.insert(0, str(REPO_ROOT / "scripts")) + from cross_reference import cross_reference + + empty_db = {"files": {}, "indexes": {}} + report = cross_reference( + {"dual": DUAL_PROFILE}, {}, empty_db, standalone_cores=standalone_cores + ) + return sorted(g["name"] for g in report["dual"]["gap_details"]) + + def test_a_platform_running_it_standalone(self): + self.assertEqual(self._gaps({"dual"}), ["both.bin", "standalone.bin"]) + + def test_a_platform_running_the_core(self): + self.assertEqual(self._gaps(set()), ["both.bin", "libretro.bin"]) + + if __name__ == "__main__": unittest.main()