refactor: share the gap scope rule

This commit is contained in:
Abdessamad Derraz committed 2026-10-06 13:59:50 +02:00
1 parent fbc92c99cf
commit 9af89cb120
3 files changed
+27 -38

No files matched your search

+3 -22
View File
@@ -32,7 +32,7 @@ from common import (
resolve_local_file, resolve_local_file,
runs_standalone, runs_standalone,
) )
from validation import read_from_system_dir from validation import outside_gap_scope
yaml = require_yaml() yaml = require_yaml()
@@ -369,26 +369,7 @@ def _cross_reference_profile(
}) })
continue continue
# Skip pattern placeholders (e.g., <bios>.bin, <user-selected>.bin) if outside_gap_scope(f, is_standalone):
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"):
continue continue
archive = f.get("archive") archive = f.get("archive")
@@ -624,7 +605,7 @@ def main():
config = load_platform_config(args.platform, args.platforms_dir) config = load_platform_config(args.platform, args.platforms_dir)
relevant = resolve_platform_cores(config, profiles, target_cores=target_cores) relevant = resolve_platform_cores(config, profiles, target_cores=target_cores)
profiles = {k: v for k, v in profiles.items() if k in relevant} 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: if not profiles:
print("No emulator profiles found.", file=sys.stderr) print("No emulator profiles found.", file=sys.stderr)
+22
View File
@@ -324,6 +324,28 @@ def read_from_system_dir(file_entry: dict) -> bool:
return not load_from or load_from == "system_dir" 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]: def filter_files_by_mode(files: list[dict], standalone: bool) -> list[dict]:
"""Filter file entries by libretro/standalone mode.""" """Filter file entries by libretro/standalone mode."""
result = [] result = []
+2 -16
View File
@@ -79,7 +79,7 @@ from validation import (
check_file_validation, check_file_validation,
filter_files_by_mode, filter_files_by_mode,
find_validated_variant, find_validated_variant,
read_from_system_dir, outside_gap_scope,
) )
DEFAULT_DB = "database.json" DEFAULT_DB = "database.json"
@@ -394,21 +394,7 @@ def _candidate_verdict(
""" """
if file_entry.get("unsourceable"): if file_entry.get("unsourceable"):
return "settled" return "settled"
# Placeholders stand for a family of files, not a file. if outside_gap_scope(file_entry, is_standalone):
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"):
return "skip" return "skip"
if not include_all: if not include_all:
archive = file_entry.get("archive") archive = file_entry.get("archive")