mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-11-29 21:08:53 -06:00
feat: record slots and truth in install lists
Each entry a slot decides carries its groups and the claims of every emulator at each lookup key, so the installer replays --one-per-slot on any board. The full list marks what the --source truth list lacks and carries what only it holds, and records per emulator the files of its standalone build. slot.py keeps the claims unmerged beside the index it builds from them.
This commit is contained in:
1 parent
b1ff6c762e
commit
3b2157d981
4 files changed
+392
-45
No files matched your search
@@ -18,6 +18,7 @@ from __future__ import annotations
|
||||
from dataclasses import dataclass
|
||||
|
||||
import region as region_mod
|
||||
import slot as slot_mod
|
||||
from common import _norm_system_id, sanitize_pack_path
|
||||
from packextras import (
|
||||
_kept,
|
||||
@@ -41,6 +42,7 @@ class SelectionIndex:
|
||||
systems_by_dest: dict[str, frozenset[str]]
|
||||
declared_by: dict[str, frozenset[str]]
|
||||
extra_groups: dict[str, frozenset[str]]
|
||||
slots: dict[str, dict]
|
||||
|
||||
@classmethod
|
||||
def build(
|
||||
@@ -51,6 +53,7 @@ class SelectionIndex:
|
||||
extras: list[dict],
|
||||
required_only: bool = False,
|
||||
extras_prefix: str = "",
|
||||
slot_claims: dict[str, dict[str, dict]] | None = None,
|
||||
) -> SelectionIndex:
|
||||
by_norm: dict[str, set[str]] = {}
|
||||
for sys_id in pack_systems:
|
||||
@@ -93,6 +96,7 @@ class SelectionIndex:
|
||||
systems_by_dest,
|
||||
{dest: frozenset(ids) for dest, ids in declared_by.items()},
|
||||
{dest: frozenset(ids) for dest, ids in extra_groups.items()},
|
||||
_slot_fields(region_groups, slot_claims or {}),
|
||||
)
|
||||
|
||||
def fields(self, dest: str, name: str) -> dict:
|
||||
@@ -110,6 +114,8 @@ class SelectionIndex:
|
||||
out["systems"] = sorted(systems)
|
||||
if dest not in self.competing:
|
||||
return out
|
||||
if dest in self.slots:
|
||||
out["slot"] = self.slots[dest]
|
||||
regions = region_mod.lookup_regions(self.region_index, dest, name)
|
||||
if not regions:
|
||||
return out
|
||||
@@ -126,3 +132,63 @@ class SelectionIndex:
|
||||
if priority is not None:
|
||||
out["priority"] = priority
|
||||
return out
|
||||
|
||||
|
||||
def _slot_fields(
|
||||
region_groups: dict[str, list[tuple[str, str]]],
|
||||
claims: dict[str, dict[str, dict]],
|
||||
) -> dict[str, dict]:
|
||||
"""Per destination, the groups it competes in for a slot and the claims
|
||||
at each key slot.lookup_slot would try.
|
||||
|
||||
Only a group where some emulator ranks a member can drop a file, so
|
||||
only its members are written, each with all its groups. A key whose
|
||||
claims equal the previous one's answers the same and is left out. A
|
||||
destination no emulator claims is never dropped, and carries nothing.
|
||||
"""
|
||||
names: dict[str, list[str]] = {}
|
||||
for members in region_groups.values():
|
||||
for dest, name in members:
|
||||
if name not in names.setdefault(dest, []):
|
||||
names[dest].append(name)
|
||||
keyed: dict[str, list[str]] = {}
|
||||
for dest, found in names.items():
|
||||
keys: list[str] = []
|
||||
for name in found:
|
||||
keys += [k for k in slot_mod.slot_lookup_keys(dest, name)
|
||||
if k in claims and k not in keys]
|
||||
if keys:
|
||||
keyed[dest] = keys
|
||||
|
||||
def ranked(dest: str) -> bool:
|
||||
return any(rank is not None for key in keyed.get(dest, ())
|
||||
for claim in claims[key].values() for rank in claim["ranks"])
|
||||
|
||||
# Each time a group lists the destination: two cores filing one file in
|
||||
# a group make two candidates of one rank, which no order separates.
|
||||
groups: dict[str, list[str]] = {}
|
||||
for group_id, members in region_groups.items():
|
||||
for dest, _name in members:
|
||||
groups.setdefault(dest, []).append(group_id)
|
||||
# Every group of such a destination: one where it stays keeps it.
|
||||
written: set[str] = set()
|
||||
for members in region_groups.values():
|
||||
if any(ranked(member) for member, _name in members):
|
||||
written.update(member for member, _name in members if member in keyed)
|
||||
fields: dict[str, dict] = {}
|
||||
for dest in sorted(written):
|
||||
kept: list[dict] = []
|
||||
for key in keyed[dest]:
|
||||
by_emulator = {
|
||||
emulator: {
|
||||
"ranks": claim["ranks"],
|
||||
**({"regions": sorted(claim["regions"])} if claim["regions"] else {}),
|
||||
**({"sets": sorted(g for _owner, g in claim["sets"])}
|
||||
if claim["sets"] else {}),
|
||||
}
|
||||
for emulator, claim in sorted(claims[key].items())
|
||||
}
|
||||
if not kept or kept[-1] != by_emulator:
|
||||
kept.append(by_emulator)
|
||||
fields[dest] = {"groups": sorted(groups[dest]), "keys": kept}
|
||||
return fields
|
||||
Reference in new issue
Block a user