mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-22 17:47:48 -06:00
refactor: name the platform's own core build
The Recalbox and RetroPie exporters each rebuilt the folded core-name index that model.profiles provides, and kept one claimant of a contested name by load order (Recalbox the first, RetroPie the last). Neither read built_by. Both now read core_key_index through BaseExporter.core_profiles, and model.profiles.platform_core_profiles chooses: the builds the platform ships itself (built_by), all of them, else the claimants no platform builds on its own, the profile keyed by the name first. platform_builds carries the first half, shared with resolve.launchers. Recalbox names that change: amiberry and libretro/amiberry (amiberry-5.6.5, ROCKNIX's build, to amiberry-8.2.2), libretro/pcsx2 (lrps2-416291a, Batocera's, to pcsx2-libretro-408e3b2), bare pcsx2 (to the standalone pcsx2), libretro/px68k (px68k-sdl, RetroPie's standalone, to px68k), libretro/dosbox_pure (dosbox-pure-unleashed to dosbox_pure), libretro/vice_x64, x64sc, x128, xvic (vice to each own core). A name no profile of the written build claims falls back to either build: es_bios.xml writes libretro/fba2x for piFBA, a standalone binary. RetroPie: the amiberry package now stands for Amiberry 5.7.2 and 6.3.3, the two builds RetroPie compiles, instead of the generic profile.
This commit is contained in:
1 parent
3518e1c53c
commit
b6bd585ee4
8 files changed
+241
-81
No files matched your search
@@ -11,6 +11,8 @@ from __future__ import annotations
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Generic, TypeVar, Union
|
||||
|
||||
from core.paths import EMULATORS_DIR, REPO_ROOT
|
||||
from model.profiles import core_key_index, load_emulator_profiles, platform_core_profiles
|
||||
from resolve.reconcile import NativeFile, NativeSystem, Report
|
||||
|
||||
# What a produced file holds: text for every format, bytes besides for one
|
||||
@@ -222,6 +224,24 @@ class BaseExporter(ABC, Generic[Content]):
|
||||
reads as one value the checker never compares."""
|
||||
return None
|
||||
|
||||
def core_profiles(self, name: str, mode: str | None) -> set[str]:
|
||||
"""The profiles a core name in the platform's own file stands for,
|
||||
in the build ``mode`` it names (libretro or standalone, None for
|
||||
either).
|
||||
|
||||
The platform's own build of a name is what the name means there:
|
||||
Recalbox's libretro/pcsx2 is its PCSX2 1.7 fork, not the LRPS2
|
||||
revision Batocera builds under that name, and load order picked
|
||||
either one.
|
||||
"""
|
||||
cached = getattr(self, "_core_profiles", None)
|
||||
if cached is None:
|
||||
profiles = load_emulator_profiles(str(REPO_ROOT / EMULATORS_DIR))
|
||||
cached = (profiles, core_key_index(profiles, include_aliases=True))
|
||||
self._core_profiles = cached
|
||||
profiles, index = cached
|
||||
return platform_core_profiles(index, profiles, name, self.platform_name(), mode)
|
||||
|
||||
def required_value(self, fe: NativeFile) -> bool:
|
||||
"""The requirement the render writes for an entry.
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ from xml.sax.saxutils import quoteattr
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
|
||||
from model.profiles import load_emulator_profiles
|
||||
from core.hashing import parse_hash_list
|
||||
from model.safeparse import parse_untrusted_xml
|
||||
|
||||
@@ -33,8 +32,6 @@ SOURCE_URL = (
|
||||
"https://gitlab.com/recalbox/recalbox/-/raw/master/board/recalbox/fsoverlay"
|
||||
"/recalbox/share_init/system/.emulationstation/es_bios.xml"
|
||||
)
|
||||
# Resolved from the file: the profiles say which names each core answers to.
|
||||
EMULATORS_DIR = Path(__file__).resolve().parents[2] / "emulators"
|
||||
SCHEMA_URL = (
|
||||
"https://gitlab.com/recalbox/recalbox/-/raw/master/board/recalbox/fsoverlay"
|
||||
"/recalbox/share_init/system/.emulationstation/es_bios.xsd"
|
||||
@@ -185,17 +182,6 @@ class Exporter(BaseExporter[str]):
|
||||
return path
|
||||
return fe.destination or fe.name
|
||||
|
||||
def _profile_keys(self) -> dict[str, str]:
|
||||
"""Each name a core answers to, as Recalbox writes it, to its profile."""
|
||||
index = getattr(self, "_keys", None)
|
||||
if index is None:
|
||||
index = {}
|
||||
for key, profile in load_emulator_profiles(str(EMULATORS_DIR)).items():
|
||||
for name in (key, *(str(c) for c in profile.get("cores") or [])):
|
||||
index.setdefault(name.replace("-", "_").lower(), key)
|
||||
self._keys = index
|
||||
return index
|
||||
|
||||
def required_value(self, fe: NativeFile) -> bool:
|
||||
"""Whether the cores the element names need the file.
|
||||
|
||||
@@ -216,11 +202,14 @@ class Exporter(BaseExporter[str]):
|
||||
]
|
||||
if not entries:
|
||||
return fe.required
|
||||
index = self._profile_keys()
|
||||
named = {
|
||||
index.get(core.rsplit("/", 1)[-1].replace("-", "_").lower(), "")
|
||||
for core in fe.cores()
|
||||
} - {""}
|
||||
# Recalbox writes a libretro core under libretro/ and a standalone
|
||||
# emulator bare, mostly: its own list writes libretro/fba2x for
|
||||
# piFBA, a standalone binary. A name no profile of the build written
|
||||
# claims is the emulator of either build.
|
||||
named: set[str] = set()
|
||||
for core in fe.cores():
|
||||
mode, _, name = core.rpartition("/")
|
||||
named |= self.core_profiles(name, mode or "standalone") or self.core_profiles(name, None)
|
||||
readers: set[str] = set()
|
||||
requirers: set[str] = set()
|
||||
set_readers: set[str] = set()
|
||||
|
||||
@@ -19,7 +19,6 @@ from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
|
||||
from model.profiles import load_emulator_profiles
|
||||
from scraper.retropie_scraper import script_members
|
||||
|
||||
from .base_exporter import BaseExporter
|
||||
@@ -29,9 +28,6 @@ SOURCE_URL = (
|
||||
"https://codeload.github.com/RetroPie/RetroPie-Setup/tar.gz/refs/heads/master"
|
||||
)
|
||||
ARCHIVE = "RetroPie-Setup.tar.gz"
|
||||
# Resolved from the file rather than the working directory: the profiles
|
||||
# are what say which files a package needs.
|
||||
EMULATORS_DIR = Path(__file__).resolve().parents[2] / "emulators"
|
||||
|
||||
# The longest list RetroPie writes is six names (lr-atari800). Past that the
|
||||
# sentence stops being something a reader uses, so the names are reported
|
||||
@@ -97,24 +93,17 @@ class Exporter(BaseExporter[str]):
|
||||
if relative.startswith("scriptmodules/") and "bios" in text.lower()
|
||||
}
|
||||
|
||||
def _core_index(self) -> dict[str, dict[str, str]]:
|
||||
"""Module id (without its lr- prefix) to the profile it stands for,
|
||||
per build.
|
||||
def _module_cores(self, module_id: str) -> frozenset[str]:
|
||||
"""The profiles a package stands for.
|
||||
|
||||
An lr- package is a libretro core and a bare one a standalone
|
||||
emulator: the standalone minivmac package matched the libretro
|
||||
profile, which reads MacII.ROM where Mini vMac 37 reads vMac.ROM.
|
||||
A build RetroPie compiles itself is what its name means there, all
|
||||
of them: the amiberry package is Amiberry 5.7.2 or 6.3.3 by board.
|
||||
"""
|
||||
index: dict[str, dict[str, str]] = {"libretro": {}, "standalone": {}}
|
||||
for key, profile in load_emulator_profiles(str(EMULATORS_DIR)).items():
|
||||
kind = str(profile.get("type", ""))
|
||||
for build in ("libretro", "standalone"):
|
||||
if build not in kind:
|
||||
continue
|
||||
index[build][key.replace("-", "_").lower()] = key
|
||||
for name in profile.get("cores", []) or []:
|
||||
index[build][str(name).replace("-", "_").lower()] = key
|
||||
return index
|
||||
build = "libretro" if module_id.startswith("lr-") else "standalone"
|
||||
return frozenset(self.core_profiles(module_id.removeprefix("lr-"), build))
|
||||
|
||||
@staticmethod
|
||||
def _files_by_core(systems: dict[str, NativeSystem]) -> dict[str, list[NativeFile]]:
|
||||
@@ -246,8 +235,8 @@ class Exporter(BaseExporter[str]):
|
||||
return kept
|
||||
|
||||
@staticmethod
|
||||
def _required_for(fe: NativeFile, core: str | None) -> bool:
|
||||
"""Whether the package's own core needs the file.
|
||||
def _required_for(fe: NativeFile, cores: frozenset[str]) -> bool:
|
||||
"""Whether the package's own cores need the file.
|
||||
|
||||
The merged `required` is true when any core needs it: pcsx_rearmed
|
||||
runs in HLE without a BIOS, yet four were proposed as required for
|
||||
@@ -257,12 +246,14 @@ class Exporter(BaseExporter[str]):
|
||||
# A file the package installs is not one to copy: gngeopi's
|
||||
# gngeo_data.zip lands in its data directory with make install.
|
||||
brought = truth.get("_brought_by")
|
||||
if brought is not None and not any(b.startswith(f"{core}:") for b in brought):
|
||||
if brought is not None and not any(
|
||||
b.startswith(f"{core}:") for b in brought for core in cores
|
||||
):
|
||||
return False
|
||||
required_by = truth.get("_required_by")
|
||||
if required_by is None:
|
||||
return fe.required
|
||||
return core in required_by
|
||||
return bool(cores.intersection(required_by))
|
||||
|
||||
@staticmethod
|
||||
def _join(names: list[str], serial: bool = False) -> str:
|
||||
@@ -316,7 +307,6 @@ class Exporter(BaseExporter[str]):
|
||||
"repository: the BIOS list is a sentence inside a shell script"
|
||||
)
|
||||
|
||||
index = self._core_index()
|
||||
# A sentence grows no longer than the longest RetroPie writes itself:
|
||||
# past that it stops reading as one, and the names are reported.
|
||||
self._longest = max(len(self._listed(help_text)) for _, help_text in modules.values())
|
||||
@@ -335,13 +325,14 @@ class Exporter(BaseExporter[str]):
|
||||
produced: dict[str, str] = {}
|
||||
|
||||
for relative, (module_id, help_text) in sorted(modules.items()):
|
||||
build = "libretro" if module_id.startswith("lr-") else "standalone"
|
||||
core = index[build].get(module_id.removeprefix("lr-").replace("-", "_").lower())
|
||||
files = by_core.get(core or "", [])
|
||||
cores = self._module_cores(module_id)
|
||||
files = list({
|
||||
id(fe): fe for core in sorted(cores) for fe in by_core.get(core, [])
|
||||
}.values())
|
||||
if not files:
|
||||
self._skip("which no profiled core matches", module_id)
|
||||
continue
|
||||
new_help = self._new_help(module_id, help_text, files, core, systems_of)
|
||||
new_help = self._new_help(module_id, help_text, files, cores, systems_of)
|
||||
if new_help is None:
|
||||
continue
|
||||
produced[relative] = originals[relative].replace(
|
||||
@@ -360,7 +351,7 @@ class Exporter(BaseExporter[str]):
|
||||
module_id: str,
|
||||
help_text: str,
|
||||
files: list[NativeFile],
|
||||
core: str | None,
|
||||
cores: frozenset[str],
|
||||
systems_of: dict[str, set[str]],
|
||||
) -> str | None:
|
||||
"""The help sentence with the files it lacks, None when left as is."""
|
||||
@@ -381,7 +372,7 @@ class Exporter(BaseExporter[str]):
|
||||
fe
|
||||
for fe in files
|
||||
if not fe.foreign_system
|
||||
and self._required_for(fe, core)
|
||||
and self._required_for(fe, cores)
|
||||
and not (
|
||||
{fe.name.lower()}
|
||||
| {str(a).lower() for a in _aliases(fe)}
|
||||
|
||||
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import os
|
||||
import sys
|
||||
from collections.abc import Iterable, Mapping
|
||||
from pathlib import Path
|
||||
|
||||
from core.cli import InputMissing, suggest_names
|
||||
@@ -327,3 +328,46 @@ def preferred_profile(index: dict[str, set[str]], name: str) -> str | None:
|
||||
if not claimants:
|
||||
return None
|
||||
return name if name in claimants else sorted(claimants)[0]
|
||||
|
||||
|
||||
def platform_builds(
|
||||
claimants: Iterable[str], profiles: Mapping[str, dict], platform: str
|
||||
) -> set[str]:
|
||||
"""The claimants of a core name that a platform runs.
|
||||
|
||||
The builds the platform ships itself (``built_by``) when it names one,
|
||||
else every claimant no platform builds on its own: a revision only
|
||||
another platform compiles is not on this one. Recalbox's pcsx2 core is
|
||||
its PCSX2 1.7 fork, not the LRPS2 revision Batocera builds under that
|
||||
name.
|
||||
"""
|
||||
claimed = set(claimants)
|
||||
own = {k for k in claimed if platform in (profiles[k].get("built_by") or [])}
|
||||
return own or {k for k in claimed if not profiles[k].get("built_by")}
|
||||
|
||||
|
||||
def platform_core_profiles(
|
||||
index: Mapping[str, set[str]],
|
||||
profiles: Mapping[str, dict],
|
||||
name: str,
|
||||
platform: str,
|
||||
mode: str | None,
|
||||
) -> set[str]:
|
||||
"""The profiles a core name designates in a platform's own list.
|
||||
|
||||
``index`` is a ``core_key_index``, ``mode`` the build the list names
|
||||
(``libretro`` or ``standalone``, None for either). The platform's own builds answer
|
||||
first, all of them: RetroPie builds Amiberry 5.7.2 and 6.3.3 under one
|
||||
package, one per board. Without one, the profile whose key is the name
|
||||
does: Recalbox's vice_x64 is the vice_x64 core, not the vice profile
|
||||
that also lists it.
|
||||
"""
|
||||
key = core_key(name)
|
||||
claimants = {
|
||||
k for k in index.get(key, ())
|
||||
if mode is None or mode in str(profiles[k].get("type", ""))
|
||||
}
|
||||
builds = platform_builds(claimants, profiles, platform)
|
||||
if any(platform in (profiles[k].get("built_by") or []) for k in builds):
|
||||
return builds
|
||||
return {k for k in builds if core_key(k) == key} or builds
|
||||
@@ -23,7 +23,7 @@ from dataclasses import dataclass
|
||||
from core.hashing import HASH_FIELDS, declared_hashes
|
||||
from model.database import record_at
|
||||
from model.declarations import CONFIGS_ROOT, ROMS_ROOT, declared_root, declared_slot, outer_layout
|
||||
from model.profiles import lists_files, profile_names
|
||||
from model.profiles import lists_files, platform_builds, profile_names
|
||||
from resolve.content import name_match_size_ok
|
||||
from resolve.localfile import resolve_local_file
|
||||
from core.paths import comparable_destination, sanitize_pack_path
|
||||
@@ -435,8 +435,7 @@ def _named_profiles(record: dict, profiles: Mapping[str, dict], platform: str) -
|
||||
key for key, profile in profiles.items()
|
||||
if lists_files(profile) and part in profile_names(key, profile)
|
||||
]
|
||||
own = [k for k in named if platform in (profiles[k].get("built_by") or [])]
|
||||
found.extend(own or [k for k in named if not profiles[k].get("built_by")])
|
||||
found.extend(platform_builds(named, profiles, platform))
|
||||
return sorted(set(found))
|
||||
|
||||
|
||||
|
||||
+45
-30
@@ -16,6 +16,7 @@ import unittest
|
||||
from collections import OrderedDict
|
||||
from pathlib import Path
|
||||
|
||||
from model.profiles import core_key_index
|
||||
from resolve.reconcile import NativeFile, NativeSystem, Report, build_native_model
|
||||
from exporter.bizhawk_exporter import Exporter as BizHawk
|
||||
from exporter.misterfpga_exporter import Exporter as Mister
|
||||
@@ -651,8 +652,8 @@ class RetroPieProposals(unittest.TestCase):
|
||||
fe = NativeFile("scph5501.bin", "scph5501.bin", "psx",
|
||||
truth={"required": True, "_required_by": ["beetle_psx"],
|
||||
"_cores": ["beetle_psx", "pcsx_rearmed"]})
|
||||
self.assertTrue(RetroPie._required_for(fe, "beetle_psx"))
|
||||
self.assertFalse(RetroPie._required_for(fe, "pcsx_rearmed"))
|
||||
self.assertTrue(RetroPie._required_for(fe, frozenset({"beetle_psx"})))
|
||||
self.assertFalse(RetroPie._required_for(fe, frozenset({"pcsx_rearmed"})))
|
||||
|
||||
def test_a_file_the_package_installs_is_not_proposed(self):
|
||||
"""gngeopi's help asked to copy gngeo_data.zip, which make install
|
||||
@@ -665,8 +666,15 @@ class RetroPieProposals(unittest.TestCase):
|
||||
truth={"required": True, "_required_by": ["gngeopi"],
|
||||
"_cores": ["gngeopi"],
|
||||
"_brought_by": ["gngeopi:standalone"]})
|
||||
self.assertFalse(RetroPie._required_for(installed, "gngeopi"))
|
||||
self.assertTrue(RetroPie._required_for(brought, "gngeopi"))
|
||||
self.assertFalse(RetroPie._required_for(installed, frozenset({"gngeopi"})))
|
||||
self.assertTrue(RetroPie._required_for(brought, frozenset({"gngeopi"})))
|
||||
|
||||
@staticmethod
|
||||
def _knowing(**profiles: dict) -> RetroPie:
|
||||
"""An exporter that reads these profiles instead of emulators/."""
|
||||
exporter = RetroPie()
|
||||
exporter._core_profiles = (profiles, core_key_index(profiles, include_aliases=True))
|
||||
return exporter
|
||||
|
||||
@staticmethod
|
||||
def _module(module_id: str, help_text: str) -> dict[str, str]:
|
||||
@@ -689,46 +697,57 @@ class RetroPieProposals(unittest.TestCase):
|
||||
def test_a_module_left_as_is_is_not_written(self):
|
||||
"""minivmac was reported "left as is" for a name no profile documents
|
||||
and written all the same: the skip had no continue after it."""
|
||||
from unittest import mock
|
||||
|
||||
exporter = RetroPie()
|
||||
exporter = self._knowing(vmac={"type": "standalone"})
|
||||
module = self._module("vmac", "Copy the required BIOS file vMac.ROM to $biosdir")
|
||||
with mock.patch.object(RetroPie, "_core_index",
|
||||
return_value={"standalone": {"vmac": "vmac"}, "libretro": {}}):
|
||||
produced = exporter.render(self._wanting("vmac", "MacII.ROM"), Report(), module)
|
||||
produced = exporter.render(self._wanting("vmac", "MacII.ROM"), Report(), module)
|
||||
self.assertEqual(produced, {})
|
||||
|
||||
def test_a_standalone_package_does_not_borrow_a_libretro_profile(self):
|
||||
"""lr- was stripped whatever the build: RetroPie's standalone
|
||||
minivmac package matched the libretro profile, which reads
|
||||
MacII.ROM where Mini vMac 37 reads vMac.ROM."""
|
||||
from unittest import mock
|
||||
|
||||
module = self._module("minivmac", "Copy the required BIOS file vMac.ROM to $biosdir")
|
||||
index = {"libretro": {"minivmac": "minivmac"}, "standalone": {}}
|
||||
with mock.patch.object(RetroPie, "_core_index", return_value=index):
|
||||
exporter = RetroPie()
|
||||
produced = exporter.render(self._wanting("minivmac", "MacII.ROM"), Report(), module)
|
||||
exporter = self._knowing(minivmac={"type": "libretro"})
|
||||
produced = exporter.render(self._wanting("minivmac", "MacII.ROM"), Report(), module)
|
||||
self.assertEqual(produced, {})
|
||||
self.assertIn("minivmac", sum(exporter._skipped.values(), []))
|
||||
|
||||
def test_a_package_stands_for_every_build_retropie_compiles(self):
|
||||
"""RetroPie builds Amiberry 5.7.2 and 6.3.3 under the amiberry
|
||||
package, one per board. The last profile loaded under the name was
|
||||
the generic amiberry, which the truth never names for RetroPie, and
|
||||
the package was left as is."""
|
||||
exporter = self._knowing(**{
|
||||
"amiberry": {"type": "standalone + libretro"},
|
||||
"amiberry-5.7.2": {"type": "standalone", "cores": ["amiberry"],
|
||||
"built_by": ["retropie"]},
|
||||
"amiberry-6.3.3": {"type": "standalone", "cores": ["amiberry"],
|
||||
"built_by": ["retropie"]},
|
||||
})
|
||||
listed = NativeFile("a.rom", "a.rom", "sys", platform={"name": "a.rom"})
|
||||
wanted = self._wanting("amiberry-6.3.3", "b.rom")
|
||||
wanted["sys"].files.insert(0, listed)
|
||||
modules = {
|
||||
**self._module("amiberry", "Copy the required BIOS file a.rom to $biosdir"),
|
||||
**self._module("other", "Copy bios files x.rom, y.rom and z.rom to $biosdir"),
|
||||
}
|
||||
produced = exporter.render(wanted, Report(), modules)
|
||||
self.assertEqual(list(produced), ["scriptmodules/emulators/amiberry.sh"])
|
||||
self.assertIn("a.rom and b.rom", produced["scriptmodules/emulators/amiberry.sh"])
|
||||
|
||||
def test_a_list_is_capped_by_retropies_longest_not_a_constant(self):
|
||||
"""The cap of six came from the longest list read, case-sensitively:
|
||||
xm7 writes thirteen names."""
|
||||
from unittest import mock
|
||||
|
||||
names = [f"n{i}.rom" for i in range(8)]
|
||||
modules = {
|
||||
**self._module("long", "Copy bios files " + ", ".join(names[:7]) + " and "
|
||||
+ names[7] + " to $biosdir"),
|
||||
**self._module("short", "Copy the required BIOS files a.rom and b.rom to $biosdir"),
|
||||
}
|
||||
index = {"standalone": {"short": "short"}, "libretro": {}}
|
||||
with mock.patch.object(RetroPie, "_core_index", return_value=index):
|
||||
exporter = RetroPie()
|
||||
produced = exporter.render(
|
||||
self._wanting("short", "a.rom", "b.rom", "c.rom", "d.rom", "e.rom",
|
||||
"f.rom", "g.rom"), Report(), modules)
|
||||
exporter = self._knowing(short={"type": "standalone"})
|
||||
produced = exporter.render(
|
||||
self._wanting("short", "a.rom", "b.rom", "c.rom", "d.rom", "e.rom",
|
||||
"f.rom", "g.rom"), Report(), modules)
|
||||
self.assertEqual(len(produced), 1)
|
||||
self.assertEqual(exporter.validate({}, produced), [])
|
||||
|
||||
@@ -736,8 +755,6 @@ class RetroPieProposals(unittest.TestCase):
|
||||
"""lr-geargrafx adds pcengine only (addSystem, lr-geargrafx.sh:42),
|
||||
and its sentence was extended with the LaserActive's pac-n1.bin and
|
||||
pac-n10.bin, a system RetroPie does not have."""
|
||||
from unittest import mock
|
||||
|
||||
files = [NativeFile(n, n, sys_id, truth={
|
||||
"required": True, "_required_by": ["geargrafx"], "_cores": ["geargrafx"],
|
||||
"_brought_by": ["geargrafx:libretro"]}, foreign_system=foreign)
|
||||
@@ -750,10 +767,8 @@ class RetroPieProposals(unittest.TestCase):
|
||||
**self._module("lr-geargrafx", "Copy the required BIOS file syscard3.pce to $biosdir"),
|
||||
**self._module("xm7", "Copy bios files a.rom, b.rom and c.rom to $biosdir"),
|
||||
}
|
||||
with mock.patch.object(RetroPie, "_core_index",
|
||||
return_value={"libretro": {"geargrafx": "geargrafx"},
|
||||
"standalone": {}}):
|
||||
produced = RetroPie().render(systems, Report(), module)
|
||||
exporter = self._knowing(geargrafx={"type": "libretro"})
|
||||
produced = exporter.render(systems, Report(), module)
|
||||
(text,) = produced.values()
|
||||
self.assertIn("gexpress.pce", text)
|
||||
self.assertNotIn("pac-n1.bin", text)
|
||||
|
||||
@@ -30,6 +30,7 @@ import zipfile
|
||||
from collections import OrderedDict
|
||||
from pathlib import Path
|
||||
|
||||
from model.profiles import core_key_index
|
||||
from model.registry import list_registered_platforms
|
||||
from model.platforms import load_platform_config, native_layer
|
||||
from model.safeparse import parse_untrusted_xml
|
||||
@@ -1475,6 +1476,48 @@ class RecalboxExport(unittest.TestCase):
|
||||
declared = next(fe for s in systems.values() for fe in s.files if fe.platform)
|
||||
self.assertTrue(exporter.required_value(declared))
|
||||
|
||||
def test_a_core_name_means_recalboxs_own_build(self):
|
||||
"""libretro/pcsx2 is Recalbox's PCSX2 1.7 fork. The first profile
|
||||
loaded under the name was the LRPS2 revision Batocera builds, and its
|
||||
requirement stood for Recalbox's core."""
|
||||
scraped = {"systems": {"ps2": {"native_id": "ps2", "files": [{
|
||||
"name": "ps2.bin", "destination": "ps2/ps2.bin", "md5": "a" * 32,
|
||||
"native_system": "ps2", "required": True, "core": "libretro/pcsx2",
|
||||
}]}}}
|
||||
truth = {"systems": {"ps2": {"files": [{
|
||||
"name": "ps2.bin", "path": "ps2/ps2.bin", "md5": "a" * 32, "required": True,
|
||||
"_cores": ["lrps2-416291a", "pcsx2-libretro-408e3b2"],
|
||||
"_required_by": ["lrps2-416291a"],
|
||||
}]}}}
|
||||
profiles = {
|
||||
"lrps2-416291a": {"type": "libretro", "cores": ["pcsx2"], "built_by": ["batocera"]},
|
||||
"pcsx2-libretro-408e3b2": {"type": "libretro", "cores": ["pcsx2"],
|
||||
"built_by": ["recalbox"]},
|
||||
}
|
||||
systems, _ = build_native_model(truth, scraped)
|
||||
exporter = discover_exporters()["recalbox"]()
|
||||
exporter._core_profiles = (profiles, core_key_index(profiles, include_aliases=True))
|
||||
declared = next(fe for s in systems.values() for fe in s.files if fe.platform)
|
||||
self.assertFalse(exporter.required_value(declared))
|
||||
|
||||
def test_a_prefix_no_profile_of_that_build_claims_names_the_emulator(self):
|
||||
"""es_bios.xml writes libretro/fba2x for piFBA, a standalone binary:
|
||||
the element's reader is still piFBA."""
|
||||
scraped = {"systems": {"neogeo": {"native_id": "neogeo", "files": [{
|
||||
"name": "neogeo.zip", "destination": "neogeo.zip", "md5": "a" * 32,
|
||||
"native_system": "neogeo", "required": False, "core": "libretro/fba2x",
|
||||
}]}}}
|
||||
truth = {"systems": {"neogeo": {"files": [{
|
||||
"name": "neogeo.zip", "md5": "a" * 32, "required": True,
|
||||
"_cores": ["fba2x"], "_required_by": ["fba2x"],
|
||||
}]}}}
|
||||
profiles = {"fba2x": {"type": "standalone", "cores": ["fba2x", "pifba"]}}
|
||||
systems, _ = build_native_model(truth, scraped)
|
||||
exporter = discover_exporters()["recalbox"]()
|
||||
exporter._core_profiles = (profiles, core_key_index(profiles, include_aliases=True))
|
||||
declared = next(fe for s in systems.values() for fe in s.files if fe.platform)
|
||||
self.assertTrue(exporter.required_value(declared))
|
||||
|
||||
def test_an_element_kept_as_written_is_not_counted_lost(self):
|
||||
"""The truth takes the entry on sha1 and size and names no md5: the
|
||||
element is written back whole, and the run counted it a platform
|
||||
|
||||
@@ -14,7 +14,10 @@ import re
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from model.profiles import preferred_profile, upstream_profile_index
|
||||
from model.profiles import (
|
||||
core_key_index, platform_builds, platform_core_profiles, preferred_profile,
|
||||
upstream_profile_index,
|
||||
)
|
||||
from resolve.cores import resolve_platform_cores
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
@@ -44,5 +47,61 @@ class OneIndex(unittest.TestCase):
|
||||
self.assertIsNone(pattern.search(path.read_text(encoding="utf-8")))
|
||||
|
||||
|
||||
# The claimants of three names Recalbox and RetroPie write, as the profiles
|
||||
# declared them when both exporters kept one by load order.
|
||||
CONTESTED = {
|
||||
"lrps2": {"type": "libretro", "cores": ["lrps2", "pcsx2"]},
|
||||
"lrps2-416291a": {"type": "libretro", "cores": ["pcsx2"], "built_by": ["batocera"]},
|
||||
"pcsx2-libretro-408e3b2": {"type": "libretro", "cores": ["pcsx2"], "built_by": ["recalbox"]},
|
||||
"pcsx2": {"type": "standalone", "cores": ["pcsx2"]},
|
||||
"amiberry": {"type": "standalone + libretro", "cores": ["amiberry", "AMIBERRY"]},
|
||||
"amiberry-5.6.5": {"type": "standalone", "cores": ["amiberry"], "built_by": ["rocknix"]},
|
||||
"amiberry-5.7.2": {"type": "standalone", "cores": ["amiberry"], "built_by": ["retropie"]},
|
||||
"amiberry-6.3.3": {"type": "standalone", "cores": ["amiberry"], "built_by": ["retropie"]},
|
||||
"amiberry-8.2.2": {"type": "standalone + libretro", "cores": ["amiberry"],
|
||||
"built_by": ["recalbox"]},
|
||||
"vice": {"type": "libretro", "cores": ["vice_x64", "vice_x64sc"]},
|
||||
"vice_x64": {"type": "libretro", "cores": ["vice_x64", "x64"]},
|
||||
}
|
||||
|
||||
|
||||
class PlatformCoreProfiles(unittest.TestCase):
|
||||
"""A core name in a platform's own list means the build that platform
|
||||
ships, whatever order the profiles load in."""
|
||||
|
||||
def designated(self, name: str, platform: str, mode: str | None) -> set[str]:
|
||||
index = core_key_index(CONTESTED, include_aliases=True)
|
||||
return platform_core_profiles(index, CONTESTED, name, platform, mode)
|
||||
|
||||
def test_the_platforms_own_build_answers(self):
|
||||
self.assertEqual(self.designated("pcsx2", "recalbox", "libretro"),
|
||||
{"pcsx2-libretro-408e3b2"})
|
||||
self.assertEqual(self.designated("pcsx2", "batocera", "libretro"), {"lrps2-416291a"})
|
||||
self.assertEqual(self.designated("AMIBERRY", "recalbox", "libretro"), {"amiberry-8.2.2"})
|
||||
|
||||
def test_the_mode_named_narrows_the_claimants(self):
|
||||
self.assertEqual(self.designated("pcsx2", "recalbox", "standalone"), {"pcsx2"})
|
||||
|
||||
def test_every_own_build_of_a_name_answers(self):
|
||||
self.assertEqual(self.designated("amiberry", "retropie", "standalone"),
|
||||
{"amiberry-5.7.2", "amiberry-6.3.3"})
|
||||
|
||||
def test_another_platforms_build_never_answers(self):
|
||||
self.assertEqual(self.designated("amiberry", "lakka", "standalone"), {"amiberry"})
|
||||
self.assertEqual(self.designated("pcsx2", "lakka", "libretro"), {"lrps2"})
|
||||
|
||||
def test_the_profile_keyed_by_the_name_comes_first(self):
|
||||
self.assertEqual(self.designated("vice-x64", "recalbox", "libretro"), {"vice_x64"})
|
||||
self.assertEqual(self.designated("vice_x64sc", "recalbox", "libretro"), {"vice"})
|
||||
|
||||
def test_no_mode_reads_both_builds(self):
|
||||
self.assertEqual(self.designated("pcsx2", "lakka", None), {"pcsx2"})
|
||||
|
||||
def test_platform_builds_keeps_unbuilt_claimants(self):
|
||||
self.assertEqual(
|
||||
platform_builds({"lrps2", "lrps2-416291a"}, CONTESTED, "recalbox"), {"lrps2"}
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user