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:
Abdessamad Derraz committed 2026-11-21 10:30:51 +01:00
1 parent 3518e1c53c
commit b6bd585ee4
8 files changed
+241 -81

No files matched your search

+44
View File
@@ -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