mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
fix: offer only the core slots romfs2 reads
systemholder.py builds core.0 to core.19. The Recalbox platform core list took any core.N section, so a later slot would have been offered by the platform while no board builds it.
This commit is contained in:
1 parent
5028318e3d
commit
501b2a84f3
3 files changed
+23
-10
No files matched your search
@@ -14,6 +14,7 @@ TARGET_PREFIX = "BR2_PACKAGE_RECALBOX_TARGET_"
|
||||
# romfs2 inisettings.py loadFile: a key line is tried first, then a section.
|
||||
_INI_KEY = re.compile(r'^([^#;].*?)\s?=\s?"?(.*?)"?$')
|
||||
_INI_SECTION = re.compile(r"^\[(.*)\]")
|
||||
_CORE_SECTION = re.compile(r"core\.(\d+)(?:\.[\w-]+)?")
|
||||
# romfs2 keyvaluesettings.py loadFile, the reader configin.py uses.
|
||||
_CONFIG_KEY = re.compile(r"^([^#;].*?)\s?=\s?(.+)$")
|
||||
|
||||
@@ -25,6 +26,13 @@ class SystemIni:
|
||||
sections: dict[str, dict[str, str]]
|
||||
lines: dict[str, int]
|
||||
|
||||
def core_sections(self) -> Iterator[dict[str, str]]:
|
||||
"""Every `[core.N]` and `[core.N.<board>]` section some board builds."""
|
||||
for name, values in self.sections.items():
|
||||
slot = _CORE_SECTION.fullmatch(name)
|
||||
if slot and int(slot.group(1)) < CORE_SLOTS:
|
||||
yield values
|
||||
|
||||
def slots(self, board: str) -> Iterator[str]:
|
||||
"""The `core.N` sections a board builds: `[core.N]` or `[core.N.<board>]` alone."""
|
||||
for slot in range(CORE_SLOTS):
|
||||
|
||||
@@ -155,13 +155,10 @@ def _core_names(values: dict[str, str]) -> tuple[set[str], set[str]]:
|
||||
|
||||
def system_ini_libretro(text: str) -> set[str]:
|
||||
"""The libretro cores one Recalbox system.ini offers."""
|
||||
import re
|
||||
|
||||
return {
|
||||
values.get("core", "")
|
||||
for section, values in read_system_ini(text).sections.items()
|
||||
if re.fullmatch(r"core\.\d+(\.[\w-]+)?", section)
|
||||
and values.get("emulator") == "libretro" and values.get("core")
|
||||
for values in read_system_ini(text).core_sections()
|
||||
if values.get("emulator") == "libretro" and values.get("core")
|
||||
}
|
||||
|
||||
|
||||
@@ -196,13 +193,9 @@ def system_ini_cores(text: str) -> tuple[set[str], set[str]]:
|
||||
or a standalone emulator. es_bios.xml only names the cores that need a
|
||||
BIOS, so read alone it left most of Recalbox's cores outside the pack.
|
||||
"""
|
||||
import re
|
||||
|
||||
cores: set[str] = set()
|
||||
standalone: set[str] = set()
|
||||
for section, values in read_system_ini(text).sections.items():
|
||||
if not re.fullmatch(r"core\.\d+(\.[\w-]+)?", section):
|
||||
continue
|
||||
for values in read_system_ini(text).core_sections():
|
||||
found, alone = _core_names(values)
|
||||
cores |= found
|
||||
standalone |= alone
|
||||
|
||||
@@ -672,6 +672,18 @@ class RecalboxPerBoard(unittest.TestCase):
|
||||
path, config = found["rpi3"]
|
||||
self.assertEqual((path, config.enabled["BR2_arm"]), ("configs/recalbox-pi3_defconfig", 2))
|
||||
|
||||
def test_core_slots_stop_where_systemholder_stops(self):
|
||||
"""systemholder.py reads core.0 to core.19: a later section is
|
||||
neither built on a board nor offered by the platform."""
|
||||
from scraper.recalbox_scraper import board_cores, system_ini_cores
|
||||
|
||||
ini = ("[core.20]\npackage = BR2_PACKAGE_PCSX2\nemulator = \"pcsx2\"\ncore = \"pcsx2\"\n"
|
||||
"[core.19]\npackage = BR2_PACKAGE_LIBRETRO_GAMBATTE\nemulator = \"libretro\"\n"
|
||||
"core = \"gambatte\"\n")
|
||||
enabled = {"BR2_PACKAGE_PCSX2", "BR2_PACKAGE_LIBRETRO_GAMBATTE"}
|
||||
self.assertEqual(board_cores(ini, "x86_64", enabled), {"gambatte"})
|
||||
self.assertEqual(system_ini_cores(ini), ({"gambatte"}, set()))
|
||||
|
||||
|
||||
class RetroPieModuleFlags(unittest.TestCase):
|
||||
"""The RetroPie target list read flags as requirements and libretro alone.
|
||||
|
||||
Reference in new issue
Block a user