mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-17 17:03:27 -05:00
fix: let a platform's only target filter nothing
This commit is contained in:
1 parent
8d39b1a270
commit
426d3c619d
12 files changed
+105
-266
No files matched your search
@@ -436,6 +436,14 @@ def check_targets(
|
||||
with path.open(encoding="utf-8") as fh:
|
||||
old = yaml_load(fh) or {}
|
||||
module = scrapers.get(platform)
|
||||
targets = old.get("targets") or {}
|
||||
if module is None and targets and all(
|
||||
(t or {}).get("cores", []) is None for t in targets.values()
|
||||
):
|
||||
# Every core the platform declares runs on these targets: the list
|
||||
# is the platform's own and has nothing of its own to age.
|
||||
return [Finding("targets", platform, OK, local="static",
|
||||
detail="every declared core")]
|
||||
if module is None:
|
||||
# No scraper: a hand-written file has no upstream to diff against,
|
||||
# so only its age and its core names can be reported.
|
||||
|
||||
+24
-5
@@ -437,10 +437,14 @@ def load_target_config(
|
||||
platform_name: str,
|
||||
target: str,
|
||||
platforms_dir: str = "platforms",
|
||||
) -> set[str]:
|
||||
) -> set[str] | None:
|
||||
"""Load target config and return the set of core names for the given target.
|
||||
|
||||
Resolves aliases from _overrides.yml, applies add_cores/remove_cores.
|
||||
A target whose cores are null runs every core the platform declares and
|
||||
returns None, which filters nothing: the platforms with a single target
|
||||
(RetroBat on Windows, RetroDECK, RomM in the browser) kept a hand list
|
||||
that dropped 98 RetroBat cores and 300 RetroDECK ones.
|
||||
Raises ValueError if target is unknown (with list of available targets).
|
||||
Raises FileNotFoundError if no target file exists for the platform.
|
||||
"""
|
||||
@@ -470,7 +474,10 @@ def load_target_config(
|
||||
msg += f"\nAliases: {', '.join(sorted(aliases))}"
|
||||
raise ValueError(msg)
|
||||
|
||||
cores = set(str(c) for c in targets[canonical].get("cores", []))
|
||||
declared = (targets[canonical] or {}).get("cores")
|
||||
if declared is None:
|
||||
return None
|
||||
cores = set(str(c) for c in declared)
|
||||
return apply_target_overrides(cores, overrides, canonical)
|
||||
|
||||
|
||||
@@ -515,18 +522,30 @@ def list_available_targets(
|
||||
result = []
|
||||
for tname, tdata in sorted(data.get("targets", {}).items()):
|
||||
aliases = (overrides.get(tname) or {}).get("aliases", [])
|
||||
cores = {str(c) for c in tdata.get("cores", [])}
|
||||
declared = (tdata or {}).get("cores")
|
||||
# None: the target runs every core the platform declares.
|
||||
count = (
|
||||
None if declared is None
|
||||
else len(apply_target_overrides({str(c) for c in declared}, overrides, tname))
|
||||
)
|
||||
result.append(
|
||||
{
|
||||
"name": tname,
|
||||
"architecture": tdata.get("architecture", ""),
|
||||
"core_count": len(apply_target_overrides(cores, overrides, tname)),
|
||||
"architecture": (tdata or {}).get("architecture", ""),
|
||||
"core_count": count,
|
||||
"aliases": aliases,
|
||||
}
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
def target_listing_line(row: dict) -> str:
|
||||
"""One --list-targets row, as verify and generate_pack print it."""
|
||||
aliases = f" (aliases: {', '.join(row['aliases'])})" if row["aliases"] else ""
|
||||
count = "all" if row["core_count"] is None else str(row["core_count"])
|
||||
return f" {row['name']:30s} {row['architecture']:10s} {count:>4s} cores{aliases}"
|
||||
|
||||
|
||||
HASH_EXACT_RESOLUTION_STATUSES = frozenset(
|
||||
{
|
||||
"sha1_exact",
|
||||
|
||||
@@ -30,6 +30,7 @@ from pathlib import Path
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from common import resolve_platform_cores as _platform_cores
|
||||
from common import (
|
||||
target_listing_line,
|
||||
suggest_names,
|
||||
require_platform,
|
||||
apply_target_overrides,
|
||||
@@ -2897,10 +2898,7 @@ def main():
|
||||
print(f"No targets configured for platform '{args.platform}'")
|
||||
return
|
||||
for t in targets:
|
||||
aliases = f" (aliases: {', '.join(t['aliases'])})" if t["aliases"] else ""
|
||||
print(
|
||||
f" {t['name']:30s} {t['architecture']:10s} {t['core_count']:>4d} cores{aliases}"
|
||||
)
|
||||
print(target_listing_line(t))
|
||||
return
|
||||
|
||||
_validate_args(args, parser)
|
||||
|
||||
+2
-4
@@ -34,6 +34,7 @@ import slots
|
||||
|
||||
sys.path.insert(0, os.path.dirname(__file__))
|
||||
from common import (
|
||||
target_listing_line,
|
||||
suggest_names,
|
||||
require_platform,
|
||||
archive_entry,
|
||||
@@ -2029,10 +2030,7 @@ def _run_listing(args: argparse.Namespace, parser: argparse.ArgumentParser) -> N
|
||||
print(f"No targets configured for platform '{args.platform}'")
|
||||
return
|
||||
for t in targets:
|
||||
aliases = f" (aliases: {', '.join(t['aliases'])})" if t["aliases"] else ""
|
||||
print(
|
||||
f" {t['name']:30s} {t['architecture']:10s} {t['core_count']:>4d} cores{aliases}"
|
||||
)
|
||||
print(target_listing_line(t))
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
Reference in new issue
Block a user