mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-23 20:29:06 -05:00
chore: merge round 4 fixes (profiles)
This commit is contained in:
commit
43fe5a7b15
15 files changed
+354
-29
No files matched your search
@@ -614,9 +614,12 @@ def _collect_all_aliases(files: dict) -> dict:
|
||||
["sgb2_bios.bin", "sgb2_boot.bin", "sgb2.boot.rom"],
|
||||
["sgb1.program.rom", "SGB1.sfc/program.rom"],
|
||||
["sgb2.program.rom", "SGB2.sfc/program.rom"],
|
||||
# Nintendo DS
|
||||
["bios7.bin", "nds7.bin"],
|
||||
["bios9.bin", "nds9.bin"],
|
||||
# Nintendo DS. DraStic opens nds_bios_arm9.bin, nds_bios_arm7.bin
|
||||
# and nds_firmware.bin and checks their size only: the collection
|
||||
# answers those names with its DS dumps.
|
||||
["NDS_Bios7.bin", "bios7.bin", "nds7.bin", "nds_bios_arm7.bin"],
|
||||
["NDS_Bios9.bin", "bios9.bin", "nds9.bin", "nds_bios_arm9.bin"],
|
||||
["NDS_Lite_Firmware.bin", "nds_firmware.bin"],
|
||||
["dsi_sd_card.bin", "nds_sd_card.bin"],
|
||||
# MSX
|
||||
["MSX.ROM", "MSX.rom", "Machines/Shared Roms/MSX.rom"],
|
||||
|
||||
+31
-6
@@ -22,10 +22,23 @@ from dataclasses import dataclass
|
||||
|
||||
from common import declared_root, name_match_size_ok, sanitize_pack_path
|
||||
|
||||
# The kinds whose names say which file the launcher opens. The others hand
|
||||
# over a directory, copy a file the platform already names, or let the
|
||||
# The kinds whose names say which file the launcher opens. A link of a named
|
||||
# file is one too: ROCKNIX links /storage/roms/bios/nds_bios_arm9.bin into
|
||||
# DraStic's system folder, so that is the path the emulator reads. The others
|
||||
# hand over a directory, copy a file the platform already names, or let the
|
||||
# emulator choose.
|
||||
PLACE_KINDS = ("names_searched", "fixed_name", "core_option")
|
||||
PLACE_KINDS = ("names_searched", "fixed_name", "core_option", "links")
|
||||
|
||||
# How each launcher extractor spells the BIOS directory in search_dir, as the
|
||||
# platform's own scripts name it: RetroPie's scriptmodules ($biosdir,
|
||||
# retropie_launchers.BIOSDIR), EmuDeck's EmuScripts (${biosPath},
|
||||
# emudeck_launchers.BIOS) and RetroDECK's framework ($bios_path,
|
||||
# retrodeck_launchers.BIOS).
|
||||
BIOS_ROOT_TOKENS = ("$biosdir", "${biosdir}", "${biosPath}", "$bios_path", "${bios_path}")
|
||||
|
||||
# A path spelled from a home or filesystem root names the BIOS directory by
|
||||
# its base name: /userdata/bios, ~/roms/bios, $HOME/RetroPie/BIOS.
|
||||
_ROOTED = ("/", "~/", "$HOME/", "$home/", "${HOME}/")
|
||||
|
||||
_LABELLED = re.compile(r"^([^\s()]+\.[A-Za-z0-9]+) \([^()]*\)$")
|
||||
_PLACEHOLDER = re.compile(r"\{(\w+)\}")
|
||||
@@ -68,19 +81,22 @@ class LauncherPlace:
|
||||
option or a system leaves that default in use elsewhere, and a core
|
||||
option offers a file the user may choose without ever choosing it.
|
||||
"""
|
||||
return self.kind in ("names_searched", "fixed_name") and not self.conditional
|
||||
return (
|
||||
self.kind in ("names_searched", "fixed_name", "links")
|
||||
and not self.conditional
|
||||
)
|
||||
|
||||
|
||||
def _bios_relative(directory: str, base: str) -> str | None:
|
||||
"""A launcher directory relative to the BIOS root, None when it is not one."""
|
||||
directory = directory.strip().rstrip("/")
|
||||
roots = {base, "<system_directory>"}
|
||||
roots = {base, "<system_directory>", *BIOS_ROOT_TOKENS}
|
||||
head, _, rest = directory.partition("/")
|
||||
if directory in roots:
|
||||
return ""
|
||||
if head in roots:
|
||||
relative = rest
|
||||
elif directory.startswith("/") and base and f"/{base}/" in f"{directory}/":
|
||||
elif directory.startswith(_ROOTED) and base and f"/{base}/" in f"{directory}/":
|
||||
relative = f"{directory}/".split(f"/{base}/", 1)[1].rstrip("/")
|
||||
else:
|
||||
return None
|
||||
@@ -390,9 +406,18 @@ class LauncherLayer:
|
||||
if isinstance(filled, dict):
|
||||
added.append(filled)
|
||||
if place.stands_for_default:
|
||||
# The emulator opens the launcher's file instead of its
|
||||
# own name, so a copy under that name is read by nobody:
|
||||
# EmuDeck passes Complex_4627v1.03.bin to xemu, which then
|
||||
# never opens Complex_4627.bin. A held file sitting on one
|
||||
# of the place's own paths is what fills it.
|
||||
own = {place.fold(p) for p in place.paths}
|
||||
settled.update(
|
||||
id(report) for _candidate, report in matched
|
||||
if not report.get("in_repo")
|
||||
or place.fold(sanitize_pack_path(
|
||||
report.get("path") or report.get("name", "")
|
||||
)) not in own
|
||||
)
|
||||
return added, settled
|
||||
|
||||
|
||||
@@ -48,6 +48,11 @@ OUTSIDE_BIOS: dict[str, tuple[str, ...]] = {
|
||||
"gngeopi": ("-B",), # gngeo -B/--biospath <directory of neogeo.zip>
|
||||
}
|
||||
|
||||
# Packages whose emulator reads its system files below the working directory
|
||||
# the generated launch script enters with pushd, a folder outside $biosdir:
|
||||
# DraStic opens system/<name> under it. Each must still pushd.
|
||||
WORKING_DIRECTORY: tuple[str, ...] = ("drastic",)
|
||||
|
||||
_FUNCTION = re.compile(r"^function\s+([\w.+-]+)\s*\(\)\s*\{\s*$")
|
||||
_ASSIGN = re.compile(r"^(?:local\s+)?([A-Za-z_]\w*)=(.*)$")
|
||||
_DECLARE = re.compile(r"^local\s+([A-Za-z_]\w*(?:\s+[A-Za-z_]\w*)*)\s*$")
|
||||
@@ -518,6 +523,7 @@ class PackageReader:
|
||||
if links:
|
||||
self._links(links)
|
||||
self._outside_bios(events)
|
||||
self._working_directory(events)
|
||||
return self.records
|
||||
|
||||
@staticmethod
|
||||
@@ -821,6 +827,32 @@ class PackageReader:
|
||||
)
|
||||
|
||||
|
||||
def _working_directory(self, events: list[Event]) -> None:
|
||||
"""The folder a generated launch script enters before it runs the emulator."""
|
||||
if self.package.id not in WORKING_DIRECTORY:
|
||||
return
|
||||
found = False
|
||||
for event in events:
|
||||
if not event.heredoc or not event.words or event.words[0] != ["pushd"]:
|
||||
continue
|
||||
script = _redirect_target(event.opener)
|
||||
if script is None or len(event.words) != 2 or len(event.words[1]) != 1:
|
||||
raise LauncherPatternMissing(
|
||||
f"{event.path}:{event.line}", f"pushd outside a launch script: {event.raw}"
|
||||
)
|
||||
found = True
|
||||
self.record(
|
||||
"passes_path", [], [(event.path, event.line)],
|
||||
search_dir=event.words[1][0].strip("\"'"),
|
||||
passes_to=f"working directory of {script}",
|
||||
fails_when_missing=False, depends_on_option=self._depends(event),
|
||||
)
|
||||
if not found:
|
||||
raise LauncherPatternMissing(
|
||||
self.package.path, "the launch script no longer enters a working directory"
|
||||
)
|
||||
|
||||
|
||||
def _redirect_target(words: list[list[str]]) -> str | None:
|
||||
"""The file a `cat > FILE << EOF` or `cat << EOF >> FILE` line writes."""
|
||||
flat = [w[0] for w in words if w]
|
||||
|
||||
Reference in new issue
Block a user