chore: merge round 4 fixes (links)

Both branches extracted RetroBat's Flycast BiosPath: value_folders
already produces the record, so the dedicated extractor is dropped and
its test reads the generic one.
This commit is contained in:
Abdessamad Derraz committed 2026-10-21 13:19:44 +02:00
commit f2c0d13ab2
15 files changed
+773 -10

No files matched your search

+41 -1
View File
@@ -647,6 +647,46 @@ def gsplus(cg: Configgen) -> list[Launcher]:
)]
# Generators that hand a directory of /userdata/bios to the emulator through
# its environment, with the module holding their path constants.
ENVIRONMENT_GENERATORS = (("flycast.flycastGenerator", "flycast/flycastPaths.py"),)
def environment_directories(cg: Configgen) -> list[Launcher]:
"""Command(..., env={KEY: <path under BIOS>}) in the generator."""
launchers = []
for module, paths_module in ENVIRONMENT_GENERATORS:
src = cg.generator(module)
constants = dict(cg.paths)
for node in cg.source(f"{GENERATORS}/{paths_module}").tree.body:
name = _assigned_name(node)
value = _path_value(getattr(node, "value", None), constants)
if name is not None and value is not None:
constants[name] = value
prefix = cg.bios.rstrip("/")
found = [
(key.value, value, key)
for call in _calls(src.tree, attr="Command")
for keyword in call.keywords
if keyword.arg == "env" and isinstance(keyword.value, ast.Dict)
for key, item in zip(keyword.value.keys, keyword.value.values)
if isinstance(key, ast.Constant)
and (value := _path_value(item, constants)) is not None
and (value == prefix or value.startswith(prefix + "/"))
]
if not found:
src.fail("the command environment names no /userdata/bios directory")
launchers.extend(
Launcher(
emulator=cg.emulator(module), build="standalone", kind="passes_path",
names=[], search_dir=value, passes_to=f"environment {key}",
source_ref=src.ref([(node.lineno, node.end_lineno)]),
)
for key, value, node in found
)
return launchers
# libretro core options whose value names the BIOS file the core opens.
FILE_OPTIONS = (("_o2em_options", "o2em_bios"), ("_neocd_options", "neocd_bios"))
@@ -701,7 +741,7 @@ def core_file_options(cg: Configgen) -> list[Launcher]:
EXTRACTORS: tuple[Callable[[Configgen], list[Launcher]], ...] = (
duckstation, duckstation_legacy, hatari, xemu, melonds, mupen64plus,
x16emu, gsplus, core_file_options,
x16emu, gsplus, environment_directories, core_file_options,
)
+28 -4
View File
@@ -231,6 +231,25 @@ def launcher_revision(url: str) -> str:
return found.group(1)
RETROARCH_SCRIPT = "functions/EmuScripts/emuDeckRetroArch.sh"
def installed_libretro_cores(script: str) -> list[str]:
"""The cores RetroArch_installCores downloads, without the _libretro suffix."""
body = re.search(r"RetroArch_installCores\(\)\s*\{(.*?)\n\}", script, re.S)
array = re.search(r"RAcores=\((.*?)\)", body.group(1), re.S) if body else None
if array is None:
raise RuntimeError(f"{RETROARCH_SCRIPT}: no RAcores list in RetroArch_installCores")
cores = [
word.removesuffix("_libretro")
for word in array.group(1).replace("\\", " ").split()
if word.endswith("_libretro")
]
if not cores:
raise RuntimeError(f"{RETROARCH_SCRIPT}: RAcores names no core")
return cores
class Scraper(BaseScraper):
"""Scraper for EmuDeck checkBIOS.sh and CSV cheat sheets."""
@@ -451,6 +470,9 @@ class Scraper(BaseScraper):
version = fetch_github_latest_version("dragoonDorise/EmuDeck")
cores = self._fetch_installed_emulators()
standalone = [core for core in cores if core != "retroarch"]
tree = RepoTree.github(EMUDECK_REPO, launcher_revision(self.checkbios_url))
libretro = set(installed_libretro_cores(tree.read(RETROARCH_SCRIPT)))
return {
"platform": "EmuDeck",
@@ -469,12 +491,14 @@ class Scraper(BaseScraper):
# Dolphin, Cemu, xemu, ARMSX2 and Supermodel ran with the libretro
# layout and lost their standalone-only files. A profile with no
# standalone build keeps its layout (runs_standalone).
"standalone_cores": [core for core in cores if core != "retroarch"],
"standalone_cores": standalone,
# RetroArch_installCores downloads a libretro build of some of
# them (flycast_libretro reads system/dc/ beside the standalone
# Flycast's flycast/bios/): both layouts are packed.
"dual_mode_cores": [core for core in standalone if core in libretro],
"systems": systems,
# Read at the commit checkBIOS.sh comes from.
"launchers": extract_launchers(
RepoTree.github(EMUDECK_REPO, launcher_revision(self.checkbios_url))
),
"launchers": extract_launchers(tree),
}
def _fetch_installed_emulators(self) -> list[str]:
+47
View File
@@ -612,6 +612,52 @@ def links(tree: RepoTree) -> list[Launcher]:
return records
# Packages whose build patch replaces the function an emulator resolves a
# directory with by a fixed path: ROCKNIX's Flycast returns
# /storage/roms/dreamcast/data as its data directory, which start_flycast.sh
# then links to the BIOS tree.
DIRECTORY_PATCHES = (
("flycast", f"{STANDALONE}/flycast-sa/patches/000-conf-dir.patch", "find_user_data_dir"),
)
def patched_directories(tree: RepoTree) -> list[Launcher]:
records = []
for emulator, path, function in DIRECTORY_PATCHES:
lines = tree.read(path).splitlines()
target = next(
(line[len("+++ b/"):] for line in lines if line.startswith("+++ b/")), None
)
start = next(
(n for n, line in enumerate(lines, 1) if re.search(rf"\b{function}\(\)", line)),
None,
)
returned = None
if target is not None and start is not None:
returned = next(
(
(n, match.group(1))
for n, line in enumerate(lines[start:], start + 1)
if (match := re.match(r'^\+\s*return "(/[^"]+)";', line))
),
None,
)
if returned is None:
raise LauncherPatternMissing(path, f"{function}() patched to return a fixed path")
number, directory = returned
records.append(Launcher(
emulator=emulator,
build="standalone",
kind="passes_path",
names=[],
source_ref=source_ref([(path, {start, number})]),
search_dir=directory.rstrip("/"),
passes_to=f"{function}() in {target} returns it",
fails_when_missing=False,
))
return records
def _existence_guard(script: Script, link: Link) -> int | None:
"""The line of a -e test of the BIOS-side path the link waits for, if any."""
last = max(link.lines)
@@ -639,6 +685,7 @@ EXTRACTORS: tuple[Callable[[RepoTree], list[Launcher]], ...] = (
duckstation,
aethersx2,
armsx2,
patched_directories,
links,
)