fix: place xroar ROMs in each rompath

XRoar reads a ROM by name from the directories of rompath. The entries
take their file name as path, relative to ~/.xroar/roms or
${prefix}/share/xroar/roms, and rompath and -rompath are declared as
search lists.

Batocera records its rompath line, Recalbox -rompath bios/<system>
(the placeholder its extractor already writes), RetroBat its -rompath
as two records, bios/dragon and bios/coco for coco. An entry whose
name the platform list does not declare follows the launch its
profile system is listed under: Recalbox lists mc10.rom under
trs80coco, so alice.rom is read there.

Batocera ROMs move from the BIOS root to bios/xroar, Recalbox ROMs to
bios/dragon and bios/trs80coco, RetroBat ROMs to bios/dragon and
bios/coco. RetroDECK and RetroPie keep them at the BIOS root.
This commit is contained in:
Abdessamad Derraz committed 2026-11-09 19:41:40 +01:00
1 parent e6dbbe69ed
commit 8ec0c5482c
13 files changed
+279 -19

No files matched your search

+38 -1
View File
@@ -41,6 +41,7 @@ from scraper.recalbox_launchers import ( # noqa: E402
RETROARCH,
SOURCE_FILES,
XEMU,
XROAR,
Configgen,
Launcher,
LauncherShapeError,
@@ -57,6 +58,7 @@ from scraper.recalbox_launchers import ( # noqa: E402
pcsx2,
system_directories,
xemu,
xroar,
)
from tests.test_launchers import placed # noqa: E402
@@ -109,6 +111,9 @@ LAUNCHER_BLOCKS = {
80: ''' elif emulator == "pcsx2":
module = __import__("configgen.generators.pcsx2.pcsx2Generator", fromlist=["Pcsx2Generator"])
generatorClass = getattr(module, "Pcsx2Generator")''',
122: ''' elif emulator == "xroar":
module = __import__("configgen.generators.xroar.xroarGenerator", fromlist=["XroarGenerator"])
generatorClass = getattr(module, "XroarGenerator")''',
125: ''' elif emulator == "xemu":
module = __import__("configgen.generators.xemu.xemuGenerator", fromlist=["XemuGenerator"])
generatorClass = getattr(module, "XemuGenerator")''',
@@ -1184,6 +1189,22 @@ from configgen.controllers.controller import InputItem, ControllerPerPlayer, Con
mupenSettings.setString(section, "IPL-ROM", "")''',
}
# xroarGenerator.py:1-26 at 10.1.1
XROAR_BLOCKS = {
8: '''class XroarGenerator(Generator):
def generate(self, system: Emulator, playersControllers: ControllerPerPlayer, recalboxOptions: keyValueSettings, args) -> Command:
# Make save dir
import os
import configgen.recalboxFiles as recalboxFiles''',
22: ''' snapFile: str = os.path.basename(args.rom) + ".sna"
commandArray: List[str] = [recalboxFiles.recalboxBins[system.Emulator],
"-vo", "sdl", "-ui", "sdl", "-ao", "pulse",
"-rompath", os.path.join(recalboxFiles.BIOS, args.system),
"-snappath", os.path.join(snapshotFolder, snapFile)]''',
}
BLOCKS = {
FILES_MODULE: FILES_MODULE_BLOCKS,
LAUNCHER: LAUNCHER_BLOCKS,
@@ -1199,6 +1220,7 @@ BLOCKS = {
DOLPHIN: DOLPHIN_BLOCKS,
XEMU: XEMU_BLOCKS,
MUPEN_CONFIG: MUPEN_CONFIG_BLOCKS,
XROAR: XROAR_BLOCKS,
}
@@ -1220,6 +1242,21 @@ def ref(path: str, lines: str) -> str:
return f"{path}:{lines}"
class XroarRomPath(unittest.TestCase):
def test_the_rom_path_is_the_bios_folder_of_the_system(self):
(record,) = xroar(configgen())
self.assertEqual(
(record.emulator, record.kind, record.search_dir, record.passes_to, record.source_ref),
("xroar", "passes_path", "/recalbox/share/bios/<system>", "command line -rompath",
ref(XROAR, "25")),
)
def test_a_rom_path_built_another_way_raises(self):
cg = configgen(XROAR, "os.path.join(recalboxFiles.BIOS, args.system)", "args.rompath")
with self.assertRaises(LauncherShapeError):
xroar(cg)
class SystemDirectoryPerCore(unittest.TestCase):
"""libretroRetroarch.py:431-529, the directory RetroArch is given."""
@@ -1511,7 +1548,7 @@ class ExtractionNeverEmpty(unittest.TestCase):
records = extract_launchers(reader)
self.assertEqual(sorted(set(read)), sorted(SOURCE_FILES))
self.assertEqual(len(records), 85)
self.assertEqual(len(records), 86)
def test_records_fit_the_schema(self):
schema = json.loads((REPO_ROOT / "schemas" / "platform.schema.json").read_text())
+11 -2
View File
@@ -1149,8 +1149,17 @@ class FolderArguments(unittest.TestCase):
)
def test_xroar_reassigned_folder_and_config_line(self):
argument, config = rl.xroar(_sources(**{f"{G}/Xroar.Generator.cs": XROAR}))
self.assertEqual(argument["search_dir"], 'bios/dragon, or bios/coco when system == "coco"')
# romPath is bios/dragon, rewritten to bios/coco for the coco system.
default, coco, config = rl.xroar(_sources(**{f"{G}/Xroar.Generator.cs": XROAR}))
self.assertEqual(
(default["search_dir"], default["passes_to"], default.get("systems")),
("bios/dragon", "command line -rompath bios/dragon", None),
)
self.assertEqual(
(coco["search_dir"], coco["passes_to"], coco["systems"]),
("bios/coco", "command line -rompath bios/coco", ["coco"]),
)
self.assertEqual(coco["source_ref"], default["source_ref"])
self.assertEqual(config["search_dir"], "bios/dragon")
self.assertEqual(
config["passes_to"], 'xroar.conf rompath ".\\\\..\\\\..\\\\bios\\\\dragon"'
+58 -1
View File
@@ -259,7 +259,7 @@ class PerSystem(unittest.TestCase):
def test_a_system_placeholder_gives_one_directory_per_system(self) -> None:
# Recalbox passes -rompath os.path.join(BIOS, args.system).
cfg = {
**config(passes("emu", "/recalbox/share/bios/{system}", "command line -rompath")),
**config(passes("emu", "/recalbox/share/bios/<system>", "command line -rompath")),
"systems": {
"coco": {"native_id": "trs80coco", "files": []},
"dragon64": {"native_id": "dragon", "files": []},
@@ -285,6 +285,29 @@ class PerSystem(unittest.TestCase):
)
class SystemFamily(unittest.TestCase):
def test_an_entry_follows_the_launch_its_system_is_listed_under(self) -> None:
# Recalbox lists mc10.rom under trs80coco: alice.rom, of the same
# profile system, is read there too.
profile = {
"emulator": "Emu", "type": "standalone", "standalone_pools": {"-rompath": ""},
"files": [
{"name": "mc10.rom", "path": "mc10.rom", "system": "mc10"},
{"name": "alice.rom", "path": "alice.rom", "system": "mc10"},
],
}
cfg = {
**config(passes("emu", "/recalbox/share/bios/<system>", "-rompath")),
"systems": {"coco": {"native_id": "trs80coco",
"files": [{"name": "mc10.rom"}]}},
}
((view, _standalone),) = platform_layouts("emu", profile, standalone_set(cfg))
self.assertEqual(
[f.get("standalone_path") for f in view["files"]],
["trs80coco/mc10.rom", "trs80coco/alice.rom"],
)
class Layout(unittest.TestCase):
LINKED = link("emu", "$biosdir/dc", "$home/.local/share/emu is a symlink to it")
@@ -537,3 +560,37 @@ class OpenmsxOnEachPlatform(unittest.TestCase):
self.assertTrue(
entry["standalone_path"].startswith("openmsx/"), entry["standalone_path"]
)
class XroarOnEachPlatform(unittest.TestCase):
"""XRoar reads each ROM from a directory of rompath. Batocera writes
rompath bios/xroar, RetroDECK lists $bios_path in it, RetroPie links
the build's ${prefix}/share/xroar/roms to $biosdir, RetroBat passes
-rompath bios/coco for coco and bios/dragon otherwise, Recalbox
-rompath bios/<system>."""
# Platform -> profile system -> folder, "" for the BIOS root.
EXPECTED = {
"batocera": dict.fromkeys(("dragon32", "dragon64", "coco", "coco3", "mc10"), "xroar"),
"retrodeck": dict.fromkeys(("dragon32", "dragon64", "coco", "coco3", "mc10"), ""),
"retropie": dict.fromkeys(("dragon32", "dragon64", "coco", "coco3", "mc10"), ""),
"retrobat": {**dict.fromkeys(("dragon32", "dragon64", "coco3", "mc10"), "dragon"),
"coco": "coco"},
"recalbox": {**dict.fromkeys(("dragon32", "dragon64"), "dragon"),
**dict.fromkeys(("coco", "coco3", "mc10"), "trs80coco")},
}
@classmethod
def setUpClass(cls) -> None:
cls.profile = load_emulator_profiles(str(REPO_ROOT / "emulators"))["xroar"]
def test_each_rom_lands_where_its_launch_reads_it(self) -> None:
for platform, folders in self.EXPECTED.items():
cfg = load_platform_config(platform, str(REPO_ROOT / "platforms"))
(view, _standalone), = platform_layouts("xroar", self.profile, standalone_set(cfg))
for entry in view["files"]:
with self.subTest(platform=platform, name=entry["name"]):
self.assertNotIn("unplaced", entry)
folder = folders[entry["system"]]
expected = f"{folder}/{entry['name']}" if folder else entry["name"]
self.assertEqual(entry["standalone_path"], expected)