fix: rank slots with the platform's own cores

This commit is contained in:
Abdessamad Derraz committed 2026-10-17 01:35:39 +02:00
1 parent 820d544d7d
commit 5c969a3651
3 files changed
+46 -1

No files matched your search

+2 -1
View File
@@ -490,7 +490,8 @@ def _select_variants(
for sys_id, members in region_groups.items()
}
slot_drops, slot_undecidable = slot_mod.resolve_slot_drops(
slot_groups, slot_mod.build_slot_index(emu_profiles or {})
slot_groups,
slot_mod.platform_slot_index(config, emu_profiles or {}, target_cores),
)
region_drops = region_drops | slot_drops
if slot_undecidable:
+15
View File
@@ -30,6 +30,21 @@ from __future__ import annotations
BIOS_CATEGORY = "bios"
def platform_slot_index(
config: dict, profiles: dict, target_cores: set[str] | None = None
) -> dict[str, dict]:
"""The slot index of the emulators a platform runs, nothing else.
Built over every profile, DuckStation, ePSXe and Rustation ranked the
PlayStation BIOS of RomM, whose cores rank none of them, and
`--one-per-slot` dropped four images RomM declares.
"""
from common import resolve_platform_cores # noqa: PLC0415
cores = resolve_platform_cores(config, profiles, target_cores=target_cores)
return build_slot_index({n: profiles[n] for n in cores if n in profiles})
def build_slot_index(profiles: dict) -> dict[str, dict]:
"""Map a file key to its slot metadata, keyed by path then name."""
index: dict[str, dict] = {}
+29
View File
@@ -40,5 +40,34 @@ class OnlyThePlatformsCores(unittest.TestCase):
self.assertIn("platform_region_index(", source, module)
class OnlyThePlatformsCoresRankASlot(unittest.TestCase):
"""RomM runs beetle_psx and pcsx_rearmed, which rank no PlayStation
BIOS; DuckStation's ranks dropped four images RomM declares."""
PROFILES = {
"beetle_psx": {"emulator": "Beetle", "type": "libretro",
"systems": ["sony-playstation"],
"files": [{"name": "scph100.bin"}, {"name": "scph5501.bin"}]},
"duckstation": {"emulator": "DuckStation", "type": "standalone",
"systems": ["sony-playstation"],
"files": [{"name": "scph100.bin", "priority": 10},
{"name": "scph5501.bin", "priority": 5}]},
}
def test_a_foreign_rank_orders_nothing(self):
import slot as slot_mod # noqa: PLC0415
config = {"cores": ["beetle_psx"], "systems": {"sony-playstation": {"files": []}}}
index = slot_mod.platform_slot_index(config, self.PROFILES)
self.assertIsNone(index["scph100.bin"]["rank"])
self.assertEqual(slot_mod.build_slot_index(self.PROFILES)["scph100.bin"]["rank"], 10)
def test_the_pack_reads_it(self):
source = (REPO_ROOT / "scripts" / "generate_pack.py").read_text(encoding="utf-8")
self.assertNotIn("build_slot_index(", source)
self.assertIn("platform_slot_index(", source)
if __name__ == "__main__":
unittest.main()