mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-20 18:59:07 -05:00
fix: name a target only where it narrows the pack
This commit is contained in:
1 parent
9c154a29b9
commit
4246d9ec66
3 files changed
+32
-2
No files matched your search
@@ -511,6 +511,17 @@ def _target_alias_index(targets: dict, overrides: dict) -> dict[str, str]:
|
||||
return alias_index
|
||||
|
||||
|
||||
def platform_files_target(platform: str, target: str, platforms_dir: str = "platforms") -> bool:
|
||||
"""Whether the platform's targets file knows this target, by any alias."""
|
||||
targets_dir = os.path.join(platforms_dir, "targets")
|
||||
target_file = os.path.join(targets_dir, f"{platform}.yml")
|
||||
if not os.path.exists(target_file):
|
||||
return False
|
||||
with open(target_file) as f:
|
||||
targets = (yaml_load(f) or {}).get("targets", {})
|
||||
return target in _target_alias_index(targets, _target_overrides(platform, targets_dir))
|
||||
|
||||
|
||||
def canonical_target_name(
|
||||
platforms: list[str], target: str, platforms_dir: str = "platforms"
|
||||
) -> str:
|
||||
|
||||
@@ -53,6 +53,7 @@ from common import (
|
||||
list_emulator_profiles,
|
||||
list_platform_system_ids,
|
||||
canonical_target_name,
|
||||
platform_files_target,
|
||||
list_registered_platforms,
|
||||
list_system_ids,
|
||||
load_data_dir_registry,
|
||||
@@ -227,9 +228,11 @@ def _platform_target(
|
||||
Named once for the whole run, a target two platforms file differently
|
||||
(rpi4: Batocera's bcm2711, Recalbox's rpi4_64) kept the typed name under
|
||||
--all and took the platform's own under --platform, so --verify-packs
|
||||
looked for a pack the --all build had named otherwise.
|
||||
looked for a pack the --all build had named otherwise. A platform that
|
||||
does not file the target is packed whole under --all, and its name
|
||||
claims no narrowing: BizHawk_..._Switch_BIOS_Pack.zip was the full pack.
|
||||
"""
|
||||
if not target:
|
||||
if not target or not platform_files_target(platform_name, target, platforms_dir):
|
||||
return None
|
||||
return canonical_target_name([platform_name], target, platforms_dir)
|
||||
|
||||
|
||||
@@ -35,5 +35,21 @@ class CheckReadsTheTargetLikeTheBuild(unittest.TestCase):
|
||||
self.assertTrue(cores)
|
||||
|
||||
|
||||
class ANameClaimsOnlyANarrowingThatHappened(unittest.TestCase):
|
||||
"""--all --target switch packed BizHawk and MiSTer whole, and named them
|
||||
BizHawk_..._Switch_BIOS_Pack.zip with a README saying 'cores available
|
||||
on switch'."""
|
||||
|
||||
def test_a_platform_without_the_target_is_named_plainly(self):
|
||||
from generate_pack import _narrowings, _platform_target
|
||||
|
||||
platforms = str(REPO_ROOT / "platforms")
|
||||
self.assertIsNone(_platform_target("bizhawk", "switch", platforms))
|
||||
self.assertEqual(_narrowings("full", None, None, False, False), [])
|
||||
self.assertEqual(
|
||||
_platform_target("retroarch", "nx", platforms), "nintendo-switch"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user