mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-12 13:03:54 -06:00
refactor: read the roms root from romfolders
platforms/romfolders/<platform>.yml records the roms root from the OS's own source (roms_root path and from_bios), the same fact the registry's roms_directory restated for ROCKNIX alone. The manifest's roms_directory now carries from_bios, which the installer follows from a BIOS folder of the platform's name, and the registry key is gone. A list that installs above its BIOS folder (AmberELEC) holds its roms root in the install tree: a file a launcher runs from there is a plain dest. emulators_directory stays in the registry: no rom folders file names emulator folders.
This commit is contained in:
1 parent
8633db0a22
commit
3db2819150
12 files changed
+180
-52
No files matched your search
+50
-2
@@ -509,6 +509,14 @@ def load_platform_config(platform_name: str, platforms_dir: str = "platforms") -
|
||||
# The registry key, which per-platform profile fields (installed_on,
|
||||
# not_bundled_on) name: the display name differs (MiSTer FPGA).
|
||||
config["_key"] = platform_name
|
||||
# Where the platform's games live, as its rom folders file records it
|
||||
# from the OS's own source (platforms/romfolders/<key>.yml, roms_root).
|
||||
romfolders = os.path.join(platforms_dir, "romfolders", f"{platform_name}.yml")
|
||||
if os.path.exists(romfolders):
|
||||
with open(romfolders) as f:
|
||||
roms_root = (source_yaml(f) or {}).get("roms_root")
|
||||
if isinstance(roms_root, dict):
|
||||
config["_roms_root"] = roms_root
|
||||
_platform_config_cache[cache_key] = config
|
||||
return config
|
||||
|
||||
@@ -2755,7 +2763,7 @@ def standalone_set(config: dict) -> set[str]:
|
||||
names |= {
|
||||
HANDED_PREFIX + json.dumps(
|
||||
[h.emulator, h.folder, h.directory, sorted(h.handles), h.source_ref,
|
||||
h.roms_folder]
|
||||
h.roms_place]
|
||||
)
|
||||
for h in handed_directories(config)
|
||||
}
|
||||
@@ -2791,7 +2799,9 @@ def _handed(standalone_cores: Iterable[str]) -> list:
|
||||
if not tag.startswith(HANDED_PREFIX):
|
||||
continue
|
||||
emulator, folder, directory, handles, ref, roms = json.loads(tag[len(HANDED_PREFIX):])
|
||||
found.append(HandedDirectory(emulator, folder, directory, frozenset(handles), ref, roms))
|
||||
found.append(HandedDirectory(
|
||||
emulator, folder, directory, frozenset(handles), ref, tuple(roms) if roms else None
|
||||
))
|
||||
return found
|
||||
|
||||
|
||||
@@ -2818,6 +2828,39 @@ EMULATORS_ROOT = "emulators"
|
||||
OUTER_ROOTS = (ROMS_ROOT, EMULATORS_ROOT)
|
||||
|
||||
|
||||
def outer_layout(config: dict, root: str) -> dict | None:
|
||||
"""Where a platform keeps the folder an outer root names, or None.
|
||||
|
||||
roms: the roms root its rom folders file records (``path``, the OS's
|
||||
spelling, and ``from_bios``, relative to the BIOS folder), with the
|
||||
BIOS folder's own name, base_destination, that a run's folder must
|
||||
carry before ``from_bios`` is followed from it. emulators: the
|
||||
registry's ``emulators_directory``, the folders a launcher searches
|
||||
for an emulator by key, which no rom folders file describes.
|
||||
"""
|
||||
if root == ROMS_ROOT:
|
||||
found = config.get("_roms_root") or {}
|
||||
base = str(config.get("base_destination") or "")
|
||||
path, relation = found.get("path"), found.get("from_bios")
|
||||
if not (path and relation) or "<" in str(path):
|
||||
return None
|
||||
if base:
|
||||
return {"path": str(path), "from_bios": str(relation), "bios_folder": base}
|
||||
# A list whose dests start above the BIOS folder (AmberELEC's
|
||||
# bios/...) installs into the folder holding it: a roms root there
|
||||
# or below is part of the install tree, written as a plain dest.
|
||||
declared = declared_root(config)
|
||||
if not declared:
|
||||
return None
|
||||
inside = os.path.normpath(f"{declared}/{relation}")
|
||||
if inside == ".." or inside.startswith("../"):
|
||||
return None
|
||||
return {"path": str(path), "install_prefix": "" if inside == "." else inside}
|
||||
if root == EMULATORS_ROOT:
|
||||
return config.get("emulators_directory") or None
|
||||
return None
|
||||
|
||||
|
||||
def standalone_layout_path(entry: dict, profile: dict) -> str | None:
|
||||
"""The path of an entry relative to the directories its standalone build declares.
|
||||
|
||||
@@ -2908,6 +2951,11 @@ def platform_layouts(
|
||||
tree, path = placed
|
||||
moved = {**f, "standalone_path": path,
|
||||
"layout_path": standalone_layout_path(f, profile)}
|
||||
if tree == "install":
|
||||
# Below the roms root inside the install tree (AmberELEC's
|
||||
# /storage/roms): a plain dest the platform prefix skips.
|
||||
files.append({**moved, "unprefixed": True})
|
||||
continue
|
||||
# A file the launcher runs from the roms directory (ROCKNIX's
|
||||
# roms/pico-8) or an emulator folder (RetroBat's emulators/pico8)
|
||||
# is relative to it, and says so.
|
||||
|
||||
Reference in new issue
Block a user