mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-10 21:43:23 -05:00
fix: give system packs their core extras
This commit is contained in:
1 parent
1b40211366
commit
af357a2931
2 files changed
+65
-36
No files matched your search
+29
-36
@@ -968,8 +968,16 @@ def generate_pack(
|
||||
core_files = []
|
||||
elif precomputed_extras is not None:
|
||||
core_files = precomputed_extras
|
||||
elif system_filter and source != "truth":
|
||||
core_files = []
|
||||
elif system_filter:
|
||||
# The systems asked for, with what their cores need: the split
|
||||
# packs get exactly this, and a full pack of one system had none.
|
||||
core_files = _extras_for_systems(
|
||||
_collect_emulator_extras(
|
||||
config, emulators_dir, db, set(), base_dest, emu_profiles,
|
||||
target_cores=target_cores, include_all=(source == "truth"),
|
||||
),
|
||||
system_filter,
|
||||
)
|
||||
else:
|
||||
core_files = _collect_emulator_extras(
|
||||
config,
|
||||
@@ -982,22 +990,6 @@ def generate_pack(
|
||||
include_all=(source == "truth"),
|
||||
)
|
||||
|
||||
# Truth mode + system_filter: filter core files by system ID
|
||||
if system_filter and source == "truth" and core_files:
|
||||
from common import _norm_system_id
|
||||
|
||||
norm_filter = {_norm_system_id(s) for s in system_filter} | set(
|
||||
system_filter
|
||||
)
|
||||
core_files = [
|
||||
fe
|
||||
for fe in core_files
|
||||
if (
|
||||
set(_extra_system_ids(fe))
|
||||
| {_norm_system_id(s) for s in _extra_system_ids(fe)}
|
||||
)
|
||||
& norm_filter
|
||||
]
|
||||
core_count = 0
|
||||
for fe in core_files:
|
||||
if required_only and fe.get("required") is False:
|
||||
@@ -1602,6 +1594,24 @@ def _group_systems_by_manufacturer(
|
||||
return groups
|
||||
|
||||
|
||||
def _extras_for_systems(extras: list[dict], system_ids: list[str]) -> list[dict]:
|
||||
"""Core extras owned by one of the given systems.
|
||||
|
||||
Extras carry their profile/system identity directly; display labels are
|
||||
presentation only and must never drive routing.
|
||||
"""
|
||||
from common import _norm_system_id
|
||||
|
||||
wanted = set(system_ids) | {_norm_system_id(s) for s in system_ids}
|
||||
return [
|
||||
fe for fe in extras
|
||||
if (
|
||||
set(_extra_system_ids(fe))
|
||||
| {_norm_system_id(s) for s in _extra_system_ids(fe)}
|
||||
) & wanted
|
||||
]
|
||||
|
||||
|
||||
def generate_split_packs(
|
||||
platform_name: str,
|
||||
platforms_dir: str,
|
||||
@@ -1662,26 +1672,9 @@ def generate_split_packs(
|
||||
)
|
||||
else:
|
||||
all_extras = []
|
||||
# Extras carry their profile/system identity directly; display labels are
|
||||
# presentation only and must never drive routing.
|
||||
from common import _norm_system_id
|
||||
|
||||
{_norm_system_id(s): s for s in systems}
|
||||
|
||||
results = []
|
||||
for group_name, group_system_ids in sorted(groups.items()):
|
||||
group_sys_set = set(group_system_ids)
|
||||
group_norm = {_norm_system_id(s) for s in group_system_ids}
|
||||
group_match = group_sys_set | group_norm
|
||||
group_extras = [
|
||||
fe
|
||||
for fe in all_extras
|
||||
if (
|
||||
set(_extra_system_ids(fe))
|
||||
| {_norm_system_id(s) for s in _extra_system_ids(fe)}
|
||||
)
|
||||
& group_match
|
||||
]
|
||||
group_extras = _extras_for_systems(all_extras, group_system_ids)
|
||||
zip_path = generate_pack(
|
||||
platform_name,
|
||||
platforms_dir,
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
"""A pack limited to some systems carries those systems' core extras.
|
||||
|
||||
With --platform and --system, the full source emptied the core extras, so
|
||||
`--source full` and `--source platform` built the same pack under two
|
||||
names; the split packs, built per system, carried them.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(REPO_ROOT / "scripts"))
|
||||
|
||||
from generate_pack import _extras_for_systems # noqa: E402
|
||||
|
||||
|
||||
class SystemExtras(unittest.TestCase):
|
||||
def test_extras_follow_their_system(self):
|
||||
extras = [
|
||||
{"name": "a", "source_system": "sony-playstation"},
|
||||
{"name": "b", "source_system": "sega-saturn"},
|
||||
{"name": "c", "source_systems": ["sony-playstation", "sony-psp"]},
|
||||
]
|
||||
picked = [e["name"] for e in _extras_for_systems(extras, ["sony-playstation"])]
|
||||
self.assertEqual(picked, ["a", "c"])
|
||||
|
||||
def test_full_source_does_not_empty_them(self):
|
||||
source = (REPO_ROOT / "scripts" / "generate_pack.py").read_text(encoding="utf-8")
|
||||
self.assertNotIn('elif system_filter and source != "truth":\n core_files = []', source)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user