From 9af89cb1209936459d3f781c084ed8b25b368512 Mon Sep 17 00:00:00 2001 From: Abdessamad Derraz <3028866+Abdess@users.noreply.github.com> Date: Tue, 6 Oct 2026 13:59:50 +0200 Subject: [PATCH] refactor: share the gap scope rule --- scripts/cross_reference.py | 25 +++---------------------- scripts/validation.py | 22 ++++++++++++++++++++++ scripts/verify.py | 18 ++---------------- 3 files changed, 27 insertions(+), 38 deletions(-) diff --git a/scripts/cross_reference.py b/scripts/cross_reference.py index 72965143..02be2fd8 100644 --- a/scripts/cross_reference.py +++ b/scripts/cross_reference.py @@ -32,7 +32,7 @@ from common import ( resolve_local_file, runs_standalone, ) -from validation import read_from_system_dir +from validation import outside_gap_scope yaml = require_yaml() @@ -369,26 +369,7 @@ def _cross_reference_profile( }) continue - # Skip pattern placeholders (e.g., .bin, .bin) - if "<" in fname or ">" in fname or "*" in fname: - continue - - # Skip UI-imported files with explicit path: null (not resolvable by pack) - if "path" in f and f["path"] is None: - continue - - # Skip the entries of the build the platform does not run - file_mode = f.get("mode", "both") - if file_mode == "standalone" and not is_standalone: - continue - if file_mode == "libretro" and is_standalone: - continue - - if not read_from_system_dir(f): - continue - - # Skip filename-agnostic files (handled by agnostic scan) - if f.get("agnostic"): + if outside_gap_scope(f, is_standalone): continue archive = f.get("archive") @@ -624,7 +605,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", [])} + standalone_cores = set(map(str, config.get("standalone_cores", []))) if not profiles: print("No emulator profiles found.", file=sys.stderr) diff --git a/scripts/validation.py b/scripts/validation.py index a166a98d..d129956b 100644 --- a/scripts/validation.py +++ b/scripts/validation.py @@ -324,6 +324,28 @@ def read_from_system_dir(file_entry: dict) -> bool: return not load_from or load_from == "system_dir" +def outside_gap_scope(file_entry: dict, is_standalone: bool) -> bool: + """Whether an entry is a file the platform's pack would carry for this build. + + Read by the gap report and by verify's undeclared-file pass, so both set + aside the same entries: a placeholder standing for a family of files, a + file the user imports through the UI (``path: null``), an entry of the + build the platform does not run, a file read outside the system + directory, and a filename-agnostic entry the builder scans for itself. + """ + name = file_entry.get("name", "") + if "<" in name or ">" in name or "*" in name: + return True + if "path" in file_entry and file_entry["path"] is None: + return True + mode = file_entry.get("mode") + if (mode == "standalone" and not is_standalone) or ( + mode == "libretro" and is_standalone + ): + return True + return not read_from_system_dir(file_entry) or bool(file_entry.get("agnostic")) + + def filter_files_by_mode(files: list[dict], standalone: bool) -> list[dict]: """Filter file entries by libretro/standalone mode.""" result = [] diff --git a/scripts/verify.py b/scripts/verify.py index aa35f1ce..55b806f3 100644 --- a/scripts/verify.py +++ b/scripts/verify.py @@ -79,7 +79,7 @@ from validation import ( check_file_validation, filter_files_by_mode, find_validated_variant, - read_from_system_dir, + outside_gap_scope, ) DEFAULT_DB = "database.json" @@ -394,21 +394,7 @@ def _candidate_verdict( """ if file_entry.get("unsourceable"): return "settled" - # Placeholders stand for a family of files, not a file. - if "<" in fname or ">" in fname or "*" in fname: - return "skip" - # An explicit null path means the user imports it through the UI. - if "path" in file_entry and file_entry["path"] is None: - return "skip" - file_mode = file_entry.get("mode") - if file_mode == "standalone" and not is_standalone: - return "skip" - if file_mode == "libretro" and is_standalone: - return "skip" - if not read_from_system_dir(file_entry): - return "skip" - # Filename-agnostic entries are answered by the builder's own scan. - if file_entry.get("agnostic"): + if outside_gap_scope(file_entry, is_standalone): return "skip" if not include_all: archive = file_entry.get("archive")