mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-12-02 14:28:54 -06:00
refactor: carry platform launches as a dataclass
standalone_set returned one string set mixing standalone names with ten JSON-tagged record kinds that every reader re-decoded. platform_launches now returns a frozen PlatformLaunches (resolve/launches.py) with typed fields, runs_standalone, is_dual, system_file_index and merged, which _build_layouts and packprobe share.
This commit is contained in:
1 parent
d3b741e423
commit
6e44a93156
34 files changed
+493
-467
No files matched your search
@@ -7,13 +7,9 @@ import json
|
||||
from collections.abc import Callable, Iterable
|
||||
|
||||
from model.targets import list_available_targets
|
||||
from resolve.launches import ContentFolder, ContentLaunches, PlatformLaunches, RomSearch
|
||||
from resolve.layout import (
|
||||
CONTENT_FOLDER_PREFIX,
|
||||
CONTENT_SCOPE_TAG,
|
||||
CONTENT_SYSTEM_TAG,
|
||||
CONTENT_TAG_PREFIXES,
|
||||
OUTSIDE_BIOS_FOLDER,
|
||||
ROM_SEARCH_PREFIX,
|
||||
placed_entry,
|
||||
standalone_layout_path,
|
||||
)
|
||||
@@ -128,9 +124,9 @@ def content_folder_boards(config: dict) -> dict[tuple[str, str], frozenset[str]
|
||||
}
|
||||
|
||||
|
||||
def content_folder_tags(config: dict) -> set[str]:
|
||||
def content_launches(config: dict) -> ContentLaunches:
|
||||
"""The roms folders a platform launches each libretro core for, and the
|
||||
ROM search paths its commands hand emulators and cores, as tags.
|
||||
ROM search paths its commands hand emulators and cores.
|
||||
|
||||
A core reading its BIOS sets beside the game (MAME 2003's osd_get_path
|
||||
gives FILETYPE_ROM the content directory) reads them in the folder of
|
||||
@@ -145,10 +141,9 @@ def content_folder_tags(config: dict) -> set[str]:
|
||||
# EmulatorJS writes the BIOS a frontend hands it and the game to
|
||||
# the root of one filesystem (data/src/emulator.js:845, 990, 1054):
|
||||
# RomM's firmware folder is beside the content.
|
||||
return {CONTENT_SYSTEM_TAG}
|
||||
tags = {CONTENT_SCOPE_TAG}
|
||||
return ContentLaunches(beside=True)
|
||||
if outer_layout(config, ROMS_ROOT) is None:
|
||||
return tags
|
||||
return ContentLaunches(scoped=True)
|
||||
rows = config.get("_rom_folders") or []
|
||||
folders = {str(r.get("folder")) for r in rows if r.get("folder")}
|
||||
boards = content_folder_boards(config)
|
||||
@@ -156,29 +151,32 @@ def content_folder_tags(config: dict) -> set[str]:
|
||||
pairs = {pair for pair, on in boards.items() if not target or on is None or target in on}
|
||||
from resolve.launchers import roms_place_of
|
||||
|
||||
def place(folder: str) -> list:
|
||||
return list(roms_place_of(config, folder) or ())
|
||||
def place(folder: str) -> tuple[str, ...]:
|
||||
return tuple(roms_place_of(config, folder) or ())
|
||||
|
||||
# Without a board, a core a folder offers on some boards only carries
|
||||
# them, for a manifest the installer narrows to one.
|
||||
tags |= {
|
||||
CONTENT_FOLDER_PREFIX + json.dumps([
|
||||
content_folders = frozenset(
|
||||
ContentFolder(
|
||||
c, f, place(f),
|
||||
None if target or (offered_on := boards.get((c, f))) is None else sorted(offered_on),
|
||||
])
|
||||
None if target or (offered_on := boards.get((c, f))) is None
|
||||
else tuple(sorted(offered_on)),
|
||||
)
|
||||
for c, f in pairs if f in folders
|
||||
}
|
||||
for row in rows:
|
||||
for search in row.get("searched_by") or []:
|
||||
for read in search.get("reads") or []:
|
||||
if read in folders:
|
||||
tags.add(ROM_SEARCH_PREFIX + json.dumps([
|
||||
str(search.get("core") or search["emulator"]), place(read),
|
||||
str(row["folder"]), sorted(search.get("machines") or []),
|
||||
bool(search.get("any_machine")), str(search.get("source_ref", "")),
|
||||
"libretro" if search.get("core") else "standalone",
|
||||
]))
|
||||
return tags
|
||||
)
|
||||
searches = frozenset(
|
||||
RomSearch(
|
||||
str(search.get("core") or search["emulator"]), place(read),
|
||||
str(row["folder"]), tuple(sorted(search.get("machines") or [])),
|
||||
bool(search.get("any_machine")), str(search.get("source_ref", "")),
|
||||
"libretro" if search.get("core") else "standalone",
|
||||
)
|
||||
for row in rows
|
||||
for search in row.get("searched_by") or []
|
||||
for read in search.get("reads") or []
|
||||
if read in folders
|
||||
)
|
||||
return ContentLaunches(scoped=True, folders=content_folders, searches=searches)
|
||||
|
||||
|
||||
# The machines ES-DE runs from a folder whose command starts the game itself
|
||||
@@ -257,12 +255,12 @@ def _rom_search_sets(
|
||||
return frozenset(found | members)
|
||||
|
||||
|
||||
def _search_reads(emu_name: str, searches: list, name: str) -> list[tuple[str, str]]:
|
||||
def _search_reads(emu_name: str, searches: list[RomSearch], name: str) -> list[tuple[str, str]]:
|
||||
"""The (tree, folder) places a passed ROM search reads this set from."""
|
||||
stem = name.rsplit(".", 1)[0]
|
||||
return sorted({
|
||||
tuple(where) for _emu, where, system, machines, any_machine, _ref, _build in searches
|
||||
if where and stem in rom_search_sets(emu_name, system, machines, any_machine)
|
||||
(s.place[0], s.place[1]) for s in searches
|
||||
if s.place and stem in rom_search_sets(emu_name, s.folder, s.machines, s.any_machine)
|
||||
})
|
||||
|
||||
|
||||
@@ -277,28 +275,29 @@ def _roms_entry(entry: dict, tree: str, folder: str, rel: str) -> dict:
|
||||
return {**entry, **where, "path": f"{folder}/{rel}", "layout_path": rel}
|
||||
|
||||
|
||||
def _content_folder_boards(tags: list[str], names: set[str]) -> dict[tuple, set[str] | None]:
|
||||
def _content_folder_boards(
|
||||
folders: Iterable[ContentFolder], names: set[str],
|
||||
) -> dict[tuple, set[str] | None]:
|
||||
"""Each roms folder the platform launches the core from, with its boards."""
|
||||
# A place keeps the boards its core is offered on there, every board
|
||||
# when one folder offers it everywhere.
|
||||
on_boards: dict[tuple, set[str] | None] = {}
|
||||
for core, _folder, where, on in (
|
||||
json.loads(t[len(CONTENT_FOLDER_PREFIX):])
|
||||
for t in tags if t.startswith(CONTENT_FOLDER_PREFIX)
|
||||
):
|
||||
if core not in names or not where:
|
||||
for folder in folders:
|
||||
if folder.core not in names or not folder.place:
|
||||
continue
|
||||
place = tuple(where)
|
||||
known = on_boards.get(place, set())
|
||||
on_boards[place] = None if on is None or known is None else known | set(on)
|
||||
known = on_boards.get(folder.place, set())
|
||||
on_boards[folder.place] = (
|
||||
None if folder.boards is None or known is None else known | set(folder.boards)
|
||||
)
|
||||
return on_boards
|
||||
|
||||
|
||||
def _libretro_content_layout(
|
||||
emu_name: str, view: dict, tags: list[str], names: set[str], searches: list,
|
||||
emu_name: str, view: dict, content: ContentLaunches, names: set[str],
|
||||
searches: list[RomSearch],
|
||||
) -> dict:
|
||||
"""The libretro layout with each file read beside the content placed there."""
|
||||
on_boards = _content_folder_boards(tags, names)
|
||||
on_boards = _content_folder_boards(content.folders, names)
|
||||
folders = sorted(on_boards)
|
||||
# The folders a passed `-rompath` replaces the build's own search
|
||||
# path with stand for these: libretro MAME hands MAME
|
||||
@@ -336,7 +335,7 @@ def _libretro_content_layout(
|
||||
return {**view, "files": out} if changed else view
|
||||
|
||||
|
||||
def _standalone_content_layout(emu_name: str, view: dict, searches: list) -> dict:
|
||||
def _standalone_content_layout(emu_name: str, view: dict, searches: list[RomSearch]) -> dict:
|
||||
"""The standalone layout with each set a passed search reads placed there."""
|
||||
pools = {str(v).strip("/") for v in (view.get("standalone_pools") or {}).values()}
|
||||
if not searches or "" not in pools:
|
||||
@@ -377,7 +376,7 @@ def _standalone_content_layout(emu_name: str, view: dict, searches: list) -> dic
|
||||
|
||||
|
||||
def content_layout(
|
||||
emu_name: str, view: dict, standalone: bool, standalone_cores: Iterable[str],
|
||||
emu_name: str, view: dict, standalone: bool, launches: PlatformLaunches,
|
||||
) -> dict:
|
||||
"""The layout with each file read in a roms folder placed in that folder.
|
||||
|
||||
@@ -387,11 +386,11 @@ def content_layout(
|
||||
entry in the folder a passed ROM search path stands for (the root of a
|
||||
standalone layout, a ``libretro_pools`` folder) also goes to each folder
|
||||
a command passes for a machine that reads it, and a standalone entry no
|
||||
launcher record places goes there only. Outside a platform (no
|
||||
CONTENT_SCOPE_TAG) the view is left as it is.
|
||||
launcher record places goes there only. Outside a platform (not
|
||||
ContentLaunches.scoped) the view is left as it is.
|
||||
"""
|
||||
tags = [t for t in standalone_cores if t.startswith(CONTENT_TAG_PREFIXES)]
|
||||
if CONTENT_SYSTEM_TAG in tags and not standalone:
|
||||
content = launches.content
|
||||
if content.beside and not standalone:
|
||||
files = [
|
||||
_without_libretro_load(f)
|
||||
if isinstance(f, dict) and _content_load(f) == "content_dir"
|
||||
@@ -399,17 +398,15 @@ def content_layout(
|
||||
for f in view.get("files") or []
|
||||
]
|
||||
return {**view, "files": files}
|
||||
if CONTENT_SCOPE_TAG not in tags:
|
||||
if not content.scoped:
|
||||
return view
|
||||
names = {core_key(n) for n in profile_names(emu_name, view)}
|
||||
searches = [
|
||||
json.loads(t[len(ROM_SEARCH_PREFIX):])
|
||||
for t in tags if t.startswith(ROM_SEARCH_PREFIX)
|
||||
]
|
||||
build = "standalone" if standalone else "libretro"
|
||||
searches = [s for s in searches if core_key(s[0]) in names and s[6] == build]
|
||||
searches = [
|
||||
s for s in content.searches if core_key(s.emulator) in names and s.build == build
|
||||
]
|
||||
if not standalone:
|
||||
return _libretro_content_layout(emu_name, view, tags, names, searches)
|
||||
return _libretro_content_layout(emu_name, view, content, names, searches)
|
||||
return _standalone_content_layout(emu_name, view, searches)
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import os
|
||||
|
||||
from model.platforms import load_platform_config
|
||||
from model.sources import source_yaml_file
|
||||
from resolve.standalone import core_dir_tags
|
||||
from resolve.standalone import core_dirs
|
||||
|
||||
|
||||
def group_identical_platforms(
|
||||
@@ -65,7 +65,7 @@ def group_identical_platforms(
|
||||
bool(config.get("case_insensitive_fs")),
|
||||
# Where each core's files go: the same cores handed other
|
||||
# folders make another pack.
|
||||
sorted(core_dir_tags(config)),
|
||||
sorted(core_dirs(config)),
|
||||
]
|
||||
fp = hashlib.sha1(f"{fp}|{emulators}".encode()).hexdigest()
|
||||
if target_cores_cache:
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
"""What a platform's launch code says about the emulators it runs."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from collections.abc import Hashable, Iterable
|
||||
from dataclasses import dataclass, field
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from resolve.launchers import ExecutedFile, HandedDirectory
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ContentFolder:
|
||||
"""A roms folder a platform launches a libretro core for, which reads beside the content."""
|
||||
|
||||
core: str
|
||||
folder: str
|
||||
# The folder as a (tree, path) place, empty when the platform gives none.
|
||||
place: tuple[str, ...]
|
||||
# The boards the folder offers the core on, None for every board.
|
||||
boards: tuple[str, ...] | None
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class RomSearch:
|
||||
"""A roms folder a system's launch command hands as ROM search path.
|
||||
|
||||
``emulator`` is a standalone emulator, or a libretro core in the command
|
||||
line it is handed as content (``build``).
|
||||
"""
|
||||
|
||||
emulator: str
|
||||
place: tuple[str, ...]
|
||||
folder: str
|
||||
machines: tuple[str, ...]
|
||||
any_machine: bool
|
||||
source_ref: str
|
||||
build: str
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class ContentLaunches:
|
||||
"""Where a platform puts the files a core reads beside the content."""
|
||||
|
||||
# The platform is known: an entry read beside the content is placed in
|
||||
# the roms folders a core is launched for, or named as read outside the
|
||||
# BIOS folder.
|
||||
scoped: bool = False
|
||||
# The frontend writes the BIOS it hands a core beside the content: the
|
||||
# folder it gives the BIOS is the content's.
|
||||
beside: bool = False
|
||||
folders: frozenset[ContentFolder] = frozenset()
|
||||
searches: frozenset[RomSearch] = frozenset()
|
||||
|
||||
|
||||
def frozen_source(source: object) -> Hashable:
|
||||
"""A profile's ``source`` in a form a set can hold: a dict by build mode, or a URL."""
|
||||
if isinstance(source, dict):
|
||||
return tuple(sorted((str(k), frozen_source(v)) for k, v in source.items()))
|
||||
if isinstance(source, list):
|
||||
return tuple(frozen_source(v) for v in source)
|
||||
return source # type: ignore[return-value]
|
||||
|
||||
|
||||
def _handed_order(position: int, handed: HandedDirectory) -> tuple[int, str]:
|
||||
"""Where a record of one platform's search lists sorts among several platforms'."""
|
||||
return position, json.dumps([
|
||||
position, handed.emulator, handed.folder, handed.directory, sorted(handed.handles),
|
||||
handed.source_ref, handed.roms_place, sorted(handed.systems), handed.holds_declared,
|
||||
])
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PlatformLaunches:
|
||||
"""The emulators a platform launches standalone and how its launchers lay them out."""
|
||||
|
||||
# The names the platform runs standalone (standalone_cores).
|
||||
standalone: frozenset[str] = frozenset()
|
||||
# The names it also launches as libretro cores.
|
||||
dual: frozenset[str] = frozenset()
|
||||
# (standalone name, profile, source): a build the platform compiles
|
||||
# itself (built_by) answers to that name there.
|
||||
own_builds: frozenset[tuple[str, str, Hashable]] = frozenset()
|
||||
# The directories its launchers hand standalone emulators, a search list
|
||||
# read in order.
|
||||
handed: tuple[HandedDirectory, ...] = ()
|
||||
# The files its launchers execute.
|
||||
executed: tuple[ExecutedFile, ...] = ()
|
||||
# (libretro core, system directory the platform hands it).
|
||||
core_dirs: frozenset[tuple[str, str]] = frozenset()
|
||||
# (system, lower-case file name or MACHINE_KEY + machine): a name the
|
||||
# platform declares under a system a launcher record is written for.
|
||||
system_files: frozenset[tuple[str, str]] = frozenset()
|
||||
content: ContentLaunches = field(default_factory=ContentLaunches)
|
||||
|
||||
def runs_standalone(self, emu_name: str, profile: dict) -> bool:
|
||||
"""Whether the platform lays this emulator's files out for its standalone build.
|
||||
|
||||
A platform names the emulators it launches standalone in
|
||||
``standalone_cores``, by profile key or by any name in ``cores:``. The
|
||||
name alone is not enough: Recalbox and Batocera call their standalone
|
||||
ScummVM ``scummvm``, which is also the key of the libretro core's
|
||||
profile, and that profile documents no standalone build. Laid out
|
||||
"standalone" it would lose every ``path:`` and drop its files at the
|
||||
root, so a profile whose ``type`` has no standalone build keeps its
|
||||
libretro layout whatever the platform calls it.
|
||||
"""
|
||||
if not self.standalone:
|
||||
return False
|
||||
if "standalone" not in str(profile.get("type", "")):
|
||||
return False
|
||||
names = {emu_name, *(str(c) for c in profile.get("cores", []))}
|
||||
# A name a build the platform compiles itself answers to means that
|
||||
# build there: RetroBat's standalone amiberry is 8.3.0, and the 8.5.0
|
||||
# profile, run there as the buildbot core, keeps its libretro layout.
|
||||
source = frozen_source(profile.get("source"))
|
||||
owners: dict[str, set[str]] = {}
|
||||
for name, owner, built in self.own_builds:
|
||||
if built == source:
|
||||
owners.setdefault(name, set()).add(owner)
|
||||
if any(emu_name not in owners[n] for n in names & owners.keys()):
|
||||
return False
|
||||
return emu_name in self.standalone or bool(self.standalone & names)
|
||||
|
||||
def is_dual(self, names: Iterable[str]) -> bool:
|
||||
"""Whether the platform also launches, as a libretro core, an emulator of these names."""
|
||||
return not self.dual.isdisjoint(names)
|
||||
|
||||
def system_file_index(self) -> dict[str, set[str]]:
|
||||
"""File name, lower case -> the platform systems declaring it."""
|
||||
index: dict[str, set[str]] = {}
|
||||
for slug, name in self.system_files:
|
||||
index.setdefault(name, set()).add(slug)
|
||||
return index
|
||||
|
||||
@classmethod
|
||||
def merged(cls, launches: Iterable[PlatformLaunches]) -> PlatformLaunches:
|
||||
"""Several platforms' launches read as one tree.
|
||||
|
||||
A per-core directory marker says which cores one platform hands a
|
||||
folder and that it hands the others none. Carried into the union,
|
||||
MinUI's 86 markers left every core they do not list without a layout:
|
||||
the global gap report lost 238 profiles and 1201 files without a word.
|
||||
Core directories and content folders stay with their platform.
|
||||
"""
|
||||
each = list(launches)
|
||||
handed = {
|
||||
(position, h) for one in each for position, h in enumerate(one.handed)
|
||||
}
|
||||
return cls(
|
||||
standalone=frozenset().union(*(one.standalone for one in each)),
|
||||
dual=frozenset().union(*(one.dual for one in each)),
|
||||
own_builds=frozenset().union(*(one.own_builds for one in each)),
|
||||
handed=tuple(h for _p, h in sorted(handed, key=lambda pair: _handed_order(*pair))),
|
||||
executed=tuple(dict.fromkeys(run for one in each for run in one.executed)),
|
||||
system_files=frozenset().union(*(one.system_files for one in each)),
|
||||
)
|
||||
+12
-124
@@ -1,90 +1,22 @@
|
||||
"""Where a platform's launch code puts a file: tag prefixes and standalone layout paths."""
|
||||
"""Where a platform's launch code puts a file: system directories and standalone layout paths."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
from collections.abc import Iterable, Mapping
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from model.profiles import profile_names
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from resolve.launches import PlatformLaunches
|
||||
|
||||
|
||||
def runs_standalone(
|
||||
emu_name: str, profile: dict, standalone_cores: set[str]
|
||||
) -> bool:
|
||||
"""Whether a platform lays this emulator's files out for its standalone build.
|
||||
|
||||
A platform names the emulators it launches standalone in
|
||||
``standalone_cores``, by profile key or by any name in ``cores:``. The
|
||||
name alone is not enough: Recalbox and Batocera call their standalone
|
||||
ScummVM ``scummvm``, which is also the key of the libretro core's
|
||||
profile, and that profile documents no standalone build. Laid out
|
||||
"standalone" it would lose every ``path:`` and drop its files at the
|
||||
root, so a profile whose ``type`` has no standalone build keeps its
|
||||
libretro layout whatever the platform calls it.
|
||||
"""
|
||||
if not standalone_cores:
|
||||
return False
|
||||
if "standalone" not in str(profile.get("type", "")):
|
||||
return False
|
||||
names = {emu_name, *(str(c) for c in profile.get("cores", []))}
|
||||
# A name a build the platform compiles itself answers to means that
|
||||
# build there: RetroBat's standalone amiberry is 8.3.0, and the 8.5.0
|
||||
# profile, run there as the buildbot core, keeps its libretro layout.
|
||||
owners: dict[str, set[str]] = {}
|
||||
for tag in standalone_cores:
|
||||
if tag.startswith(OWN_BUILD_PREFIX):
|
||||
name, owner, source = json.loads(tag[len(OWN_BUILD_PREFIX):])
|
||||
if source == profile.get("source"):
|
||||
owners.setdefault(name, set()).add(owner)
|
||||
if any(emu_name not in owners[n] for n in names & owners.keys()):
|
||||
return False
|
||||
return emu_name in standalone_cores or bool(standalone_cores & names)
|
||||
|
||||
|
||||
# Marks, in a platform's standalone set, an emulator it also launches as a
|
||||
# libretro core. No core name starts with it.
|
||||
DUAL_MODE_PREFIX = "dual:"
|
||||
# Marks, in the same set, a whole directory the platform's launcher hands a
|
||||
# standalone emulator (launchers.handed_directories), as JSON.
|
||||
HANDED_PREFIX = "handed:"
|
||||
# Marks, in the same set, a libretro core and the system directory the
|
||||
# platform hands it (``core_system_dirs``), as JSON.
|
||||
CORE_DIR_PREFIX = "coredir:"
|
||||
# Marks, in the same set, a file the platform's launcher executes
|
||||
# (launchers.executed_files), as JSON.
|
||||
EXECUTED_PREFIX = "exec:"
|
||||
# Marks, in the same set, a standalone name a build the platform compiles
|
||||
# itself (built_by) answers to, as JSON [name, profile, source].
|
||||
OWN_BUILD_PREFIX = "ownbuild:"
|
||||
# Marks, in the same set, a file name the platform declares under one of the
|
||||
# systems a launcher record is written for, as JSON [system, name]: it says
|
||||
# which launch reads a profile entry of that name.
|
||||
SYSTEM_FILE_PREFIX = "sysfile:"
|
||||
# The key, in that index, of a machine a launcher record offers.
|
||||
# The key, in a platform's system file index, of a machine a launcher record offers.
|
||||
MACHINE_KEY = "machine:"
|
||||
# The platform is known: an entry read beside the content is placed in the
|
||||
# roms folders a core is launched for, or named as read outside the BIOS
|
||||
# folder. The tags below carry those folders.
|
||||
CONTENT_SCOPE_TAG = "contentscope:"
|
||||
# [core name, roms folder, (tree, path)]: a libretro core the platform
|
||||
# launches for the games of that folder, which it reads beside.
|
||||
CONTENT_FOLDER_PREFIX = "contentdir:"
|
||||
# [emulator or core, (tree, path), system, machines, any machine,
|
||||
# source_ref, build]: a standalone emulator, or a libretro core in the
|
||||
# command line it is handed as content, given a roms folder as its ROM
|
||||
# search path by a system's launch command.
|
||||
ROM_SEARCH_PREFIX = "romsearch:"
|
||||
# The frontend writes the BIOS it hands a core beside the content: the
|
||||
# folder it gives the BIOS is the content's.
|
||||
CONTENT_SYSTEM_TAG = "contentsystem:"
|
||||
CONTENT_TAG_PREFIXES = (
|
||||
CONTENT_SCOPE_TAG, CONTENT_FOLDER_PREFIX, ROM_SEARCH_PREFIX, CONTENT_SYSTEM_TAG,
|
||||
)
|
||||
|
||||
|
||||
def core_system_dirs(
|
||||
emu_name: str, profile: dict, standalone_cores: Iterable[str]
|
||||
emu_name: str, profile: dict, launches: PlatformLaunches
|
||||
) -> list[str] | None:
|
||||
"""The system directories a platform hands this libretro core, or None.
|
||||
|
||||
@@ -93,14 +25,10 @@ def core_system_dirs(
|
||||
them (MinUI hands each launch tag its own Bios/<TAG>/) gives a core it
|
||||
lists no directory at all, so the list is then empty.
|
||||
"""
|
||||
pairs = [
|
||||
json.loads(tag[len(CORE_DIR_PREFIX):])
|
||||
for tag in standalone_cores if tag.startswith(CORE_DIR_PREFIX)
|
||||
]
|
||||
if not pairs:
|
||||
if not launches.core_dirs:
|
||||
return None
|
||||
names = set(profile_names(emu_name, profile))
|
||||
return sorted({directory for core, directory in pairs if core in names})
|
||||
return sorted({directory for core, directory in launches.core_dirs if core in names})
|
||||
|
||||
|
||||
def system_dir_view(profile: dict, directory: str) -> dict:
|
||||
@@ -129,40 +57,12 @@ def system_dir_path(entry: dict, path: str) -> str:
|
||||
return f"{directory}/{path}" if directory else path
|
||||
|
||||
|
||||
def handed_from_tags(standalone_cores: Iterable[str]) -> list:
|
||||
"""The directories a standalone set carries, as launchers built them."""
|
||||
from resolve.launchers import HandedDirectory
|
||||
|
||||
found = []
|
||||
for tag in standalone_cores:
|
||||
if not tag.startswith(HANDED_PREFIX):
|
||||
continue
|
||||
position, emulator, folder, directory, handles, ref, roms, systems, held = json.loads(
|
||||
tag[len(HANDED_PREFIX):]
|
||||
)
|
||||
found.append(((position, tag), HandedDirectory(
|
||||
emulator, folder, directory, frozenset(handles), ref,
|
||||
tuple(roms) if roms else None, frozenset(systems), held,
|
||||
)))
|
||||
return [h for _key, h in sorted(found, key=lambda pair: pair[0])]
|
||||
|
||||
|
||||
def system_file_index(standalone_cores: Iterable[str]) -> dict[str, set[str]]:
|
||||
"""File name, lower case -> the platform systems declaring it (SYSTEM_FILE_PREFIX)."""
|
||||
index: dict[str, set[str]] = {}
|
||||
for tag in standalone_cores:
|
||||
if tag.startswith(SYSTEM_FILE_PREFIX):
|
||||
slug, name = json.loads(tag[len(SYSTEM_FILE_PREFIX):])
|
||||
index.setdefault(name, set()).add(slug)
|
||||
return index
|
||||
|
||||
|
||||
def entry_launch_systems(entry: dict, index: Mapping[str, set[str]]) -> frozenset[str]:
|
||||
"""The platform systems, by our ids, that launch the emulator for an entry.
|
||||
|
||||
The systems the entry names, and those under which the platform declares
|
||||
a file of one of its names (``index``, system_file_index): Recalbox lists
|
||||
XRoar's coco3.rom under trs80coco, which our coco is.
|
||||
a file of one of its names (``index``, PlatformLaunches.system_file_index):
|
||||
Recalbox lists XRoar's coco3.rom under trs80coco, which our coco is.
|
||||
"""
|
||||
systems = {str(s) for s in entry.get("systems") or []}
|
||||
if entry.get("system"):
|
||||
@@ -173,18 +73,6 @@ def entry_launch_systems(entry: dict, index: Mapping[str, set[str]]) -> frozense
|
||||
return frozenset(systems)
|
||||
|
||||
|
||||
def _executed(standalone_cores: Iterable[str]) -> list:
|
||||
"""The files a standalone set's launchers execute, as launchers read them."""
|
||||
from resolve.launchers import ExecutedFile
|
||||
|
||||
found = []
|
||||
for tag in standalone_cores:
|
||||
if tag.startswith(EXECUTED_PREFIX):
|
||||
emulator, name, place, ref = json.loads(tag[len(EXECUTED_PREFIX):])
|
||||
found.append(ExecutedFile(emulator, name, tuple(place) if place else None, ref))
|
||||
return found
|
||||
|
||||
|
||||
# Why a standalone entry has no destination on a platform that relocates its
|
||||
# layout: the manifest's omission reason, named as the installer words it.
|
||||
OUTSIDE_BIOS_FOLDER = "outside_bios_folder"
|
||||
@@ -266,7 +154,7 @@ def standalone_destination(
|
||||
|
||||
|
||||
def standalone_bindings_for(
|
||||
emu_name: str, profile: dict, standalone_cores: Iterable[str],
|
||||
emu_name: str, profile: dict, launches: PlatformLaunches,
|
||||
systems: Iterable[str] = (),
|
||||
) -> dict[str, tuple[str, str]]:
|
||||
"""The places a platform gives this emulator's standalone layout, by subfolder.
|
||||
@@ -286,7 +174,7 @@ def standalone_bindings_for(
|
||||
if isinstance(f, dict) and (path := standalone_layout_path(f, profile))
|
||||
]
|
||||
return standalone_bindings(
|
||||
names, declared, handed_from_tags(standalone_cores), _executed(standalone_cores), layout,
|
||||
names, declared, launches.handed, launches.executed, layout,
|
||||
pools, systems,
|
||||
)
|
||||
|
||||
|
||||
@@ -762,15 +762,14 @@ def _attach_runners(
|
||||
"""
|
||||
if not scraped:
|
||||
return
|
||||
from resolve.layout import runs_standalone
|
||||
from resolve.standalone import standalone_set
|
||||
from resolve.standalone import platform_launches
|
||||
|
||||
declared = scraped.get("cores")
|
||||
libretro = {str(c) for c in declared} if isinstance(declared, list) else set()
|
||||
standalone = {str(c) for c in scraped.get("standalone_cores") or []}
|
||||
# The build decision reads the tagged set (own builds, twins), as the
|
||||
# The build decision reads the platform launches (own builds, twins), as the
|
||||
# pack does. The runner's name is looked up among the plain names.
|
||||
layout_set = standalone_set(scraped, profiles)
|
||||
launches = platform_launches(scraped, profiles)
|
||||
for system in systems.values():
|
||||
for fe in system.files:
|
||||
if fe.platform is not None or not fe.truth:
|
||||
@@ -781,7 +780,7 @@ def _attach_runners(
|
||||
sorted((key, build == "standalone") for key, _, build in
|
||||
(b.partition(":") for b in brought))
|
||||
if brought is not None
|
||||
else [(key, runs_standalone(key, profiles.get(key, {}), layout_set))
|
||||
else [(key, launches.runs_standalone(key, profiles.get(key, {})))
|
||||
for key in sorted(fe.truth.get("_cores") or ())]
|
||||
)
|
||||
for key, as_standalone in layers:
|
||||
|
||||
+91
-115
@@ -3,50 +3,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import dataclasses
|
||||
import json
|
||||
from collections.abc import Iterable, Mapping
|
||||
from collections.abc import Hashable, Iterable, Mapping
|
||||
from dataclasses import dataclass
|
||||
|
||||
from model.profiles import profile_names
|
||||
from model.systems import norm_system_id
|
||||
from resolve.contentlayout import content_folder_tags, content_layout
|
||||
from resolve.contentlayout import content_launches, content_layout
|
||||
from resolve.launches import PlatformLaunches, frozen_source
|
||||
from resolve.layout import (
|
||||
CONTENT_TAG_PREFIXES,
|
||||
CORE_DIR_PREFIX,
|
||||
DUAL_MODE_PREFIX,
|
||||
EXECUTED_PREFIX,
|
||||
HANDED_PREFIX,
|
||||
MACHINE_KEY,
|
||||
OUTSIDE_BIOS_FOLDER,
|
||||
OWN_BUILD_PREFIX,
|
||||
SYSTEM_FILE_PREFIX,
|
||||
handed_from_tags,
|
||||
placed_entry,
|
||||
core_system_dirs,
|
||||
entry_launch_systems,
|
||||
runs_standalone,
|
||||
standalone_bindings_for,
|
||||
standalone_destination,
|
||||
standalone_layout_path,
|
||||
system_dir_view,
|
||||
system_file_index,
|
||||
)
|
||||
|
||||
|
||||
def own_build_tags(
|
||||
config: dict, standalone: set[str], profiles: Mapping[str, dict]
|
||||
) -> set[str]:
|
||||
"""The standalone names the platform's own builds answer to, tagged,
|
||||
read from the run's profiles."""
|
||||
def own_builds(
|
||||
config: dict, standalone: frozenset[str], profiles: Mapping[str, dict]
|
||||
) -> frozenset[tuple[str, str, Hashable]]:
|
||||
"""The standalone names the platform's own builds answer to, as
|
||||
(name, profile, source), read from the run's profiles."""
|
||||
platform = str(config.get("_key") or "")
|
||||
if not platform or not standalone:
|
||||
return set()
|
||||
return {
|
||||
OWN_BUILD_PREFIX + json.dumps([n, key, p.get("source")])
|
||||
return frozenset()
|
||||
return frozenset(
|
||||
(n, key, frozen_source(p.get("source")))
|
||||
for key, p in profiles.items()
|
||||
if platform in (p.get("built_by") or []) and "standalone" in str(p.get("type", ""))
|
||||
for n in set(profile_names(key, p)) & standalone
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
def twin_build_names(config: dict, profiles: Mapping[str, dict]) -> set[str]:
|
||||
@@ -74,104 +64,92 @@ def twin_build_names(config: dict, profiles: Mapping[str, dict]) -> set[str]:
|
||||
return found
|
||||
|
||||
|
||||
def core_dir_tags(config: dict) -> set[str]:
|
||||
"""The system directory a platform hands each core, tagged."""
|
||||
return {
|
||||
CORE_DIR_PREFIX + json.dumps([str(core), directory])
|
||||
def core_dirs(config: dict) -> frozenset[tuple[str, str]]:
|
||||
"""The system directory a platform hands each core, as (core, directory)."""
|
||||
return frozenset(
|
||||
(str(core), directory)
|
||||
for directory, entry in (config.get("core_system_dirs") or {}).items()
|
||||
for core in entry.get("cores") or []
|
||||
)
|
||||
|
||||
|
||||
def _system_files(config: dict, handed: Iterable) -> frozenset[tuple[str, str]]:
|
||||
"""The file names a platform declares under the systems its launcher
|
||||
records name, and the machines a record offers under its systems."""
|
||||
named = {system for h in handed for system in h.systems}
|
||||
found = {
|
||||
(slug, str(f["name"]).lower())
|
||||
for slug, system in (config.get("systems") or {}).items()
|
||||
if slug in named
|
||||
for f in system.get("files") or []
|
||||
if f.get("name")
|
||||
}
|
||||
# The machines a record offers under its systems, by normalized id.
|
||||
from resolve.launchers import native_systems
|
||||
|
||||
natives = native_systems(config)
|
||||
found |= {
|
||||
(natives.get(str(native), str(native)), MACHINE_KEY + norm_system_id(str(m)))
|
||||
for record in config.get("launchers") or []
|
||||
for native in record.get("systems") or []
|
||||
for m in record.get("machines") or []
|
||||
}
|
||||
return frozenset(found)
|
||||
|
||||
|
||||
def standalone_set(config: dict, profiles: Mapping[str, dict]) -> set[str]:
|
||||
def platform_launches(config: dict, profiles: Mapping[str, dict]) -> PlatformLaunches:
|
||||
"""The emulators a platform launches standalone, with its dual-mode ones.
|
||||
|
||||
``dual_mode_cores`` names those it offers both ways (Batocera lists
|
||||
libretro:dolphin and standalone dolphin for GameCube). They travel in the
|
||||
same set, tagged, so every reader of standalone_cores sees them. A
|
||||
launcher record resting on a config file is proven against *profiles*,
|
||||
the run's, as cross-reference proves it, and the platform's own and twin
|
||||
builds are read from them.
|
||||
libretro:dolphin and standalone dolphin for GameCube). A launcher record
|
||||
resting on a config file is proven against *profiles*, the run's, as
|
||||
cross-reference proves it, and the platform's own and twin builds are
|
||||
read from them.
|
||||
"""
|
||||
names = {str(c) for c in config.get("standalone_cores") or []}
|
||||
names |= {DUAL_MODE_PREFIX + str(c) for c in config.get("dual_mode_cores") or []}
|
||||
standalone = frozenset(str(c) for c in config.get("standalone_cores") or [])
|
||||
dual = {str(c) for c in config.get("dual_mode_cores") or []}
|
||||
# A buildbot core the platform's RetroArch installs under the name of an
|
||||
# emulator it runs standalone is that emulator's libretro build: run
|
||||
# both ways, as Batocera runs amiberry standalone and can fetch
|
||||
# amiberry_libretro.
|
||||
names |= {
|
||||
DUAL_MODE_PREFIX + str(c)
|
||||
for c in set(map(str, config.get("installable_cores") or []))
|
||||
& set(map(str, config.get("standalone_cores") or []))
|
||||
}
|
||||
names |= own_build_tags(config, names, profiles)
|
||||
names |= {DUAL_MODE_PREFIX + n for n in twin_build_names(config, profiles)}
|
||||
# The system directory each core is handed travels the same way, so
|
||||
# platform_layouts places a core's files below it for every reader.
|
||||
names |= core_dir_tags(config)
|
||||
if names - {n for n in names if n.startswith(CORE_DIR_PREFIX)}:
|
||||
from resolve.launchers import executed_files, handed_directories
|
||||
dual |= set(map(str, config.get("installable_cores") or [])) & standalone
|
||||
builds = own_builds(config, standalone, profiles)
|
||||
dual |= twin_build_names(config, profiles)
|
||||
launches = PlatformLaunches(
|
||||
standalone=standalone, dual=frozenset(dual), own_builds=builds,
|
||||
# The system directory each core is handed: platform_layouts places
|
||||
# a core's files below it for every reader.
|
||||
core_dirs=core_dirs(config), content=content_launches(config),
|
||||
)
|
||||
if not (standalone or dual or builds):
|
||||
return launches
|
||||
from resolve.launchers import executed_files, handed_directories
|
||||
|
||||
handed = handed_directories(config, profiles)
|
||||
# The record's position travels too: a search list is read in order.
|
||||
names |= {
|
||||
HANDED_PREFIX + json.dumps(
|
||||
[position, h.emulator, h.folder, h.directory, sorted(h.handles), h.source_ref,
|
||||
h.roms_place, sorted(h.systems), h.holds_declared]
|
||||
)
|
||||
for position, h in enumerate(handed)
|
||||
}
|
||||
named = {system for h in handed for system in h.systems}
|
||||
names |= {
|
||||
SYSTEM_FILE_PREFIX + json.dumps([slug, str(f["name"]).lower()])
|
||||
for slug, system in (config.get("systems") or {}).items()
|
||||
if slug in named
|
||||
for f in system.get("files") or []
|
||||
if f.get("name")
|
||||
}
|
||||
# The machines a record offers under its systems, by normalized id.
|
||||
from resolve.launchers import native_systems
|
||||
|
||||
natives = native_systems(config)
|
||||
names |= {
|
||||
SYSTEM_FILE_PREFIX + json.dumps(
|
||||
[natives.get(str(native), str(native)), MACHINE_KEY + norm_system_id(str(m))]
|
||||
)
|
||||
for record in config.get("launchers") or []
|
||||
for native in record.get("systems") or []
|
||||
for m in record.get("machines") or []
|
||||
}
|
||||
names |= {
|
||||
EXECUTED_PREFIX + json.dumps([run.emulator, run.name, run.place, run.source_ref])
|
||||
for run in executed_files(config, profiles)
|
||||
}
|
||||
return names | content_folder_tags(config)
|
||||
# The record's order travels too: a search list is read in order.
|
||||
handed = tuple(handed_directories(config, profiles))
|
||||
return dataclasses.replace(
|
||||
launches,
|
||||
handed=handed,
|
||||
system_files=_system_files(config, handed),
|
||||
executed=tuple(dict.fromkeys(executed_files(config, profiles))),
|
||||
)
|
||||
|
||||
|
||||
def merged_standalone_set(configs: Iterable[dict], profiles: Mapping[str, dict]) -> set[str]:
|
||||
"""The standalone set of several platforms read as one tree.
|
||||
|
||||
A per-core directory marker says which cores one platform hands a folder
|
||||
and that it hands the others none. Carried into the union, MinUI's 86
|
||||
markers left every core they do not list without a layout: the global
|
||||
gap report lost 238 profiles and 1201 files without a word.
|
||||
"""
|
||||
return {
|
||||
tag
|
||||
for config in configs
|
||||
for tag in standalone_set(config, profiles)
|
||||
if not tag.startswith((CORE_DIR_PREFIX, *CONTENT_TAG_PREFIXES))
|
||||
}
|
||||
def merged_launches(
|
||||
configs: Iterable[dict], profiles: Mapping[str, dict]
|
||||
) -> PlatformLaunches:
|
||||
"""The launches of several platforms read as one tree (PlatformLaunches.merged)."""
|
||||
return PlatformLaunches.merged(platform_launches(config, profiles) for config in configs)
|
||||
|
||||
|
||||
def platform_layouts(
|
||||
emu_name: str, profile: dict, standalone_cores: set[str]
|
||||
emu_name: str, profile: dict, launches: PlatformLaunches
|
||||
) -> list[tuple[dict, bool]]:
|
||||
"""The layouts a platform gives an emulator: (profile, standalone?) each,
|
||||
with the files read in a roms folder placed there (content_layout)."""
|
||||
return [
|
||||
(content_layout(emu_name, view, standalone, standalone_cores), standalone)
|
||||
for view, standalone in _build_layouts(emu_name, profile, standalone_cores)
|
||||
(content_layout(emu_name, view, standalone, launches), standalone)
|
||||
for view, standalone in _build_layouts(emu_name, profile, launches)
|
||||
]
|
||||
|
||||
|
||||
@@ -181,7 +159,7 @@ class _StandaloneLaunches:
|
||||
|
||||
emu_name: str
|
||||
profile: dict
|
||||
standalone_cores: set[str]
|
||||
launches: PlatformLaunches
|
||||
per_system: bool
|
||||
index: Mapping[str, set[str]]
|
||||
# A profile system the platform launches under a system of its own, as
|
||||
@@ -196,12 +174,12 @@ class _StandaloneLaunches:
|
||||
by_systems: dict[frozenset[str], dict[str, tuple[str, str]]] = dataclasses.field(default_factory=dict)
|
||||
|
||||
@classmethod
|
||||
def of(cls, emu_name: str, profile: dict, standalone_cores: set[str]) -> _StandaloneLaunches:
|
||||
def of(cls, emu_name: str, profile: dict, launches: PlatformLaunches) -> _StandaloneLaunches:
|
||||
names = set(profile_names(emu_name, profile))
|
||||
per_system = bool(
|
||||
profile.get("standalone_directories") or profile.get("standalone_pools")
|
||||
) and any(h.systems and h.emulator in names for h in handed_from_tags(standalone_cores))
|
||||
index = system_file_index(standalone_cores) if per_system else {}
|
||||
) and any(h.systems and h.emulator in names for h in launches.handed)
|
||||
index = launches.system_file_index() if per_system else {}
|
||||
# A profile system the platform launches under a system of its own, as
|
||||
# its list says for one entry, is launched there for every entry:
|
||||
# Recalbox lists mc10.rom under trs80coco, so alice.rom is read there.
|
||||
@@ -216,7 +194,7 @@ class _StandaloneLaunches:
|
||||
# the folder its record gives, every other launch the folder the records
|
||||
# naming none give.
|
||||
named_systems = frozenset().union(*(
|
||||
h.systems for h in handed_from_tags(standalone_cores) if h.emulator in names
|
||||
h.systems for h in launches.handed if h.emulator in names
|
||||
)) if per_system else frozenset()
|
||||
|
||||
# The layout folders a search setting stands for (standalone_pools):
|
||||
@@ -225,7 +203,7 @@ class _StandaloneLaunches:
|
||||
|
||||
pool_folders = {v.strip("/") for v in _pool_folders(profile).values()} - {""}
|
||||
return cls(
|
||||
emu_name, profile, standalone_cores, per_system, index, family,
|
||||
emu_name, profile, launches, per_system, index, family,
|
||||
named_systems, pool_folders,
|
||||
)
|
||||
|
||||
@@ -248,7 +226,7 @@ class _StandaloneLaunches:
|
||||
def bindings_for(self, systems: frozenset[str]) -> dict[str, tuple[str, str]]:
|
||||
if systems not in self.by_systems:
|
||||
self.by_systems[systems] = standalone_bindings_for(
|
||||
self.emu_name, self.profile, self.standalone_cores, systems
|
||||
self.emu_name, self.profile, self.launches, systems
|
||||
)
|
||||
return self.by_systems[systems]
|
||||
|
||||
@@ -307,7 +285,7 @@ class _StandaloneLaunches:
|
||||
|
||||
|
||||
def _build_layouts(
|
||||
emu_name: str, profile: dict, standalone_cores: set[str]
|
||||
emu_name: str, profile: dict, launches: PlatformLaunches
|
||||
) -> list[tuple[dict, bool]]:
|
||||
"""The layouts a platform gives an emulator: (profile, standalone?) each.
|
||||
|
||||
@@ -316,19 +294,19 @@ def _build_layouts(
|
||||
Dolphin found dolphin-emu/Sys/GC/ empty. Each layout keeps its own rules
|
||||
(what the build reads from the system directory, where it reads it).
|
||||
"""
|
||||
if not runs_standalone(emu_name, profile, standalone_cores):
|
||||
directories = core_system_dirs(emu_name, profile, standalone_cores)
|
||||
if not launches.runs_standalone(emu_name, profile):
|
||||
directories = core_system_dirs(emu_name, profile, launches)
|
||||
if directories is None:
|
||||
return [(profile, False)]
|
||||
return [(system_dir_view(profile, d), False) for d in directories]
|
||||
standalone = profile
|
||||
launches = _StandaloneLaunches.of(emu_name, profile, standalone_cores)
|
||||
placing = _StandaloneLaunches.of(emu_name, profile, launches)
|
||||
|
||||
layout_entries = [
|
||||
f for f in profile.get("files") or []
|
||||
if isinstance(f, dict) and standalone_layout_path(f, profile) is not None
|
||||
]
|
||||
if any(launches.bindings_of(f) for f in layout_entries):
|
||||
if any(placing.bindings_of(f) for f in layout_entries):
|
||||
# The standalone view carries the platform's destination, so every
|
||||
# reader of standalone_path (builder, manifest, verify, slots) places
|
||||
# the file in the folder the platform hands the emulator.
|
||||
@@ -336,11 +314,9 @@ def _build_layouts(
|
||||
# platform keeps outside the BIOS tree: UAE4All2's kick.rom in
|
||||
# RetroPie's $md_inst. It is marked, never left at the BIOS root
|
||||
# where the emulator does not read it.
|
||||
standalone = {**profile, "files": launches.placed_files()}
|
||||
dual = {c.removeprefix(DUAL_MODE_PREFIX) for c in standalone_cores
|
||||
if c.startswith(DUAL_MODE_PREFIX)}
|
||||
if "libretro" in str(profile.get("type", "")) and dual & {
|
||||
emu_name, *(str(c) for c in profile.get("cores", []))
|
||||
}:
|
||||
standalone = {**profile, "files": placing.placed_files()}
|
||||
if "libretro" in str(profile.get("type", "")) and launches.is_dual(
|
||||
{emu_name, *(str(c) for c in profile.get("cores", []))}
|
||||
):
|
||||
return [(profile, False), (standalone, True)]
|
||||
return [(standalone, True)]
|
||||
@@ -13,7 +13,8 @@ from dataclasses import dataclass
|
||||
|
||||
from model.declarations import OUTER_ROOTS
|
||||
from model.systems import norm_system_id
|
||||
from resolve.standalone import platform_layouts, standalone_set as platform_standalone_set
|
||||
from resolve.launches import PlatformLaunches
|
||||
from resolve.standalone import platform_layouts, platform_launches
|
||||
from resolve.cores import resolve_platform_cores
|
||||
from resolve.reconcile import contradicts, shares_hash
|
||||
from model.alternatives import groups_of
|
||||
@@ -542,7 +543,7 @@ def _fold_data_directory_readers(
|
||||
systems: dict,
|
||||
profiles: dict,
|
||||
cores: list[str],
|
||||
standalone_set: set[str],
|
||||
launches: PlatformLaunches,
|
||||
platform_name: str,
|
||||
data_registry: dict,
|
||||
) -> None:
|
||||
@@ -565,7 +566,7 @@ def _fold_data_directory_readers(
|
||||
return
|
||||
for emu_name in cores:
|
||||
for view, standalone in platform_layouts(
|
||||
emu_name, profiles[emu_name], standalone_set
|
||||
emu_name, profiles[emu_name], launches
|
||||
):
|
||||
trees = [
|
||||
tree for tree in filter_files_by_mode(
|
||||
@@ -729,7 +730,7 @@ def _cover(
|
||||
|
||||
|
||||
def _platform_entries(
|
||||
emu_name: str, profile: dict, standalone_set: set[str], platform_name: str,
|
||||
emu_name: str, profile: dict, launches: PlatformLaunches, platform_name: str,
|
||||
) -> list[dict]:
|
||||
# The pack's rule (validation.deliverable), per build: a file the
|
||||
# emulator installs is kept and marked, one the launcher never opens
|
||||
@@ -741,7 +742,7 @@ def _platform_entries(
|
||||
"_brought": None if installed_with_emulator(fe, platform_name)
|
||||
else f"{emu_name}:{'standalone' if standalone else 'libretro'}",
|
||||
}
|
||||
for view, standalone in platform_layouts(emu_name, profile, standalone_set)
|
||||
for view, standalone in platform_layouts(emu_name, profile, launches)
|
||||
for fe in _system_dir_files(view, standalone)
|
||||
if not unread_on(fe, platform_name)
|
||||
])
|
||||
@@ -802,7 +803,7 @@ def generate_platform_truth(
|
||||
# The layout rule verify and the pack builder apply: truth guessed its
|
||||
# own from the profile type where the platform names no standalone
|
||||
# emulator, and kept files the pack never carries.
|
||||
standalone_set = platform_standalone_set(config, profiles)
|
||||
launches = platform_launches(config, profiles)
|
||||
|
||||
resolved = resolve_platform_cores(config, profiles, target_cores)
|
||||
|
||||
@@ -830,7 +831,7 @@ def generate_platform_truth(
|
||||
on_platform = {
|
||||
mapping.map_sys_id(sid) for sid in profile.get("systems", [])
|
||||
} & mapping.platform_sys_ids
|
||||
for fe in _platform_entries(emu_name, profile, standalone_set, platform_name):
|
||||
for fe in _platform_entries(emu_name, profile, launches, platform_name):
|
||||
sys_targets = mapping.targets(fe, profile, on_platform)
|
||||
if not sys_targets:
|
||||
unattributed[emu_name] = unattributed.get(emu_name, 0) + 1
|
||||
@@ -859,7 +860,7 @@ def generate_platform_truth(
|
||||
_cover(system_cores, sys_id, "unprofiled", emu_name)
|
||||
|
||||
_fold_data_directory_readers(
|
||||
systems, profiles, sorted(cores_profiled), standalone_set, platform_name,
|
||||
systems, profiles, sorted(cores_profiled), launches, platform_name,
|
||||
data_registry,
|
||||
)
|
||||
|
||||
|
||||
Reference in new issue
Block a user