mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-04-13 20:32:32 -05:00
fix: filter baseline systems by target-available cores
This commit is contained in:
@@ -646,6 +646,43 @@ def resolve_platform_cores(
|
||||
return result
|
||||
|
||||
|
||||
def filter_systems_by_target(
|
||||
systems: dict[str, dict],
|
||||
profiles: dict[str, dict],
|
||||
target_cores: set[str] | None,
|
||||
) -> dict[str, dict]:
|
||||
"""Filter platform systems to only those reachable by target cores.
|
||||
|
||||
A system is reachable if at least one core that emulates it is available
|
||||
on the target. Returns the filtered systems dict (or all if no target).
|
||||
"""
|
||||
if target_cores is None:
|
||||
return systems
|
||||
|
||||
# Build reverse index for target core name resolution
|
||||
upstream_to_profile: dict[str, str] = {}
|
||||
for name, p in profiles.items():
|
||||
upstream_to_profile[name] = name
|
||||
for alias in p.get("cores", []):
|
||||
upstream_to_profile[str(alias)] = name
|
||||
expanded_target = {upstream_to_profile.get(c, c) for c in target_cores}
|
||||
|
||||
# Build system -> profile keys mapping
|
||||
system_to_cores: dict[str, set[str]] = {}
|
||||
for name, p in profiles.items():
|
||||
if p.get("type") == "alias":
|
||||
continue
|
||||
for sid in p.get("systems", []):
|
||||
system_to_cores.setdefault(sid, set()).add(name)
|
||||
|
||||
filtered = {}
|
||||
for sys_id, sys_data in systems.items():
|
||||
cores_for_system = system_to_cores.get(sys_id, set())
|
||||
if cores_for_system & expanded_target:
|
||||
filtered[sys_id] = sys_data
|
||||
return filtered
|
||||
|
||||
|
||||
def _parse_validation(validation: list | dict | None) -> list[str]:
|
||||
"""Extract the validation check list from a file's validation field.
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ from common import (
|
||||
_build_validation_index, build_zip_contents_index, check_file_validation,
|
||||
check_inside_zip, compute_hashes, fetch_large_file, filter_files_by_mode,
|
||||
group_identical_platforms, list_emulator_profiles, list_registered_platforms,
|
||||
list_system_ids, load_database, load_data_dir_registry,
|
||||
load_emulator_profiles, load_platform_config, md5_composite,
|
||||
resolve_local_file,
|
||||
filter_systems_by_target, list_system_ids, load_database,
|
||||
load_data_dir_registry, load_emulator_profiles, load_platform_config,
|
||||
md5_composite, resolve_local_file,
|
||||
)
|
||||
from deterministic_zip import rebuild_zip_deterministic
|
||||
|
||||
@@ -264,8 +264,15 @@ def generate_pack(
|
||||
if emu_profiles:
|
||||
validation_index = _build_validation_index(emu_profiles)
|
||||
|
||||
# Filter systems by target if specified
|
||||
pack_systems = filter_systems_by_target(
|
||||
config.get("systems", {}),
|
||||
emu_profiles or {},
|
||||
target_cores,
|
||||
)
|
||||
|
||||
with zipfile.ZipFile(zip_path, "w", zipfile.ZIP_DEFLATED) as zf:
|
||||
for sys_id, system in sorted(config.get("systems", {}).items()):
|
||||
for sys_id, system in sorted(pack_systems.items()):
|
||||
for file_entry in system.get("files", []):
|
||||
dest = _sanitize_path(file_entry.get("destination", file_entry["name"]))
|
||||
if not dest:
|
||||
@@ -444,7 +451,7 @@ def generate_pack(
|
||||
total_files += 1
|
||||
|
||||
# Data directories from _data_dirs.yml
|
||||
for sys_id, system in sorted(config.get("systems", {}).items()):
|
||||
for sys_id, system in sorted(pack_systems.items()):
|
||||
for dd in system.get("data_directories", []):
|
||||
ref_key = dd.get("ref", "")
|
||||
if not ref_key or not data_registry or ref_key not in data_registry:
|
||||
|
||||
@@ -37,9 +37,10 @@ sys.path.insert(0, os.path.dirname(__file__))
|
||||
from common import (
|
||||
_build_validation_index, build_zip_contents_index, check_file_validation,
|
||||
check_inside_zip, compute_hashes, filter_files_by_mode,
|
||||
group_identical_platforms, list_emulator_profiles, list_system_ids,
|
||||
load_data_dir_registry, load_emulator_profiles, load_platform_config,
|
||||
md5sum, md5_composite, resolve_local_file, resolve_platform_cores,
|
||||
filter_systems_by_target, group_identical_platforms, list_emulator_profiles,
|
||||
list_system_ids, load_data_dir_registry, load_emulator_profiles,
|
||||
load_platform_config, md5sum, md5_composite, resolve_local_file,
|
||||
resolve_platform_cores,
|
||||
)
|
||||
DEFAULT_DB = "database.json"
|
||||
DEFAULT_PLATFORMS_DIR = "platforms"
|
||||
@@ -392,6 +393,11 @@ def verify_platform(
|
||||
hle_index[f.get("name", "")] = True
|
||||
validation_index = _build_validation_index(profiles)
|
||||
|
||||
# Filter systems by target
|
||||
verify_systems = filter_systems_by_target(
|
||||
config.get("systems", {}), profiles, target_cores,
|
||||
)
|
||||
|
||||
# Per-entry results
|
||||
details = []
|
||||
# Per-destination aggregation
|
||||
@@ -399,7 +405,7 @@ def verify_platform(
|
||||
file_required: dict[str, bool] = {}
|
||||
file_severity: dict[str, str] = {}
|
||||
|
||||
for sys_id, system in config.get("systems", {}).items():
|
||||
for sys_id, system in verify_systems.items():
|
||||
for file_entry in system.get("files", []):
|
||||
local_path, resolve_status = resolve_local_file(
|
||||
file_entry, db, zip_contents,
|
||||
|
||||
Reference in New Issue
Block a user