fix: read recalbox board sections as romfs does

board_cores walked only the plain [core.N] sections and replaced a board
section whole. romfs2 systemholder.py reads a slot present as
[core.N.<board>] alone (gb and gbc bsnes on x86_64) and each key from the
board section, then <key>.<board>, then the plain key. The committed
target lists are unchanged on all seven boards.
This commit is contained in:
Abdessamad Derraz committed 2026-11-04 16:48:34 +01:00
1 parent 9d3458d47a
commit a05fc599d9
2 files changed
+35 -12

No files matched your search

+21 -12
View File
@@ -211,25 +211,34 @@ def system_ini_cores(text: str) -> tuple[set[str], set[str]]:
return cores, standalone
# romfs2 systemholder.py reads core.0 to core.19.
CORE_SLOTS = 20
def board_cores(text: str, board: str, enabled: set[str]) -> set[str]:
"""The cores of one system.ini a board's image builds.
A core is built when the Buildroot package its section names is enabled
in the board's defconfig. ``[core.N.<board>]`` replaces the section on
that board and ``package.<board>`` its package.
romfs2 builds each board's list as systemholder.py does: a slot exists
as ``[core.N]`` or as ``[core.N.<board>]`` alone (gb's bsnes on x86_64),
each key is read from the board's section, then as ``<key>.<board>``,
then plain, and a core is kept when the Buildroot package it names is
enabled in the board's defconfig.
"""
import re
sections = _ini_sections(text)
cores: set[str] = set()
for section, values in sections.items():
match = re.fullmatch(r"core\.(\d+)", section)
if not match:
for slot in range(CORE_SLOTS):
plain, own = f"core.{slot}", f"core.{slot}.{board}"
if plain not in sections and own not in sections:
continue
values = sections.get(f"{section}.{board}", values)
package = values.get(f"package.{board}", values.get("package", ""))
if package in enabled:
cores |= _core_names(values)[0]
def read(key: str, plain: str = plain, own: str = own) -> str:
for where, name in ((own, key), (plain, f"{key}.{board}"), (plain, key)):
if name in sections.get(where, {}):
return sections[where][name]
return ""
if read("package") in enabled:
cores |= _core_names({"emulator": read("emulator"), "core": read("core")})[0]
return cores
+14
View File
@@ -266,6 +266,20 @@ class RecalboxPerBoard(unittest.TestCase):
self.assertEqual(defconfig_arch("BR2_arm=y\n"), "armhf")
self.assertEqual(defconfig_arch("BR2_aarch64=y\n"), "aarch64")
def test_board_sections_read_key_by_key_as_romfs_does(self):
from scraper.recalbox_scraper import board_cores # noqa: PLC0415
ini = (
"[core.0]\npackage = BR2_PACKAGE_LIBRETRO_GAMBATTE\nemulator = \"libretro\"\n"
"core = \"gambatte\"\n"
"[core.0.x86_64]\npriority = 2\n"
"[core.5.x86_64]\npackage = BR2_PACKAGE_LIBRETRO_BSNES\nemulator = \"libretro\"\n"
"core = \"bsnes\"\n"
)
enabled = {"BR2_PACKAGE_LIBRETRO_GAMBATTE", "BR2_PACKAGE_LIBRETRO_BSNES"}
self.assertEqual(board_cores(ini, "x86_64", enabled), {"gambatte", "bsnes"})
self.assertEqual(board_cores(ini, "rpi3", enabled), {"gambatte"})
class RetroPieModuleFlags(unittest.TestCase):
"""The RetroPie target list read flags as requirements and libretro alone.