Files
libretro/scripts/list_platforms.py
T
Abdessamad Derraz 83cfa6fd0f refactor: split common.py into three packages
core: cli (run_cli, input errors, name hints), github (token), paths.
model: sources, database, composition, registry, platforms,
declarations, targets, systems, profiles, cliargs. resolve: content,
ownership, datadirs, archives, localfile, directories, layout,
contentlayout, standalone, grouping, cores.

Definitions move verbatim; common.py and its re-exports are gone and
every importer, patch target and code-in-string names the new home. A
test that stubbed common.load_platform_config stubs each module that
reads the loader by its own name.
2026-11-18 11:09:13 +01:00

52 lines
1.2 KiB
Python

#!/usr/bin/env python3
"""List the platforms registered in _registry.yml.
Usage:
python scripts/list_platforms.py
python scripts/list_platforms.py >> "$GITHUB_OUTPUT"
"""
from __future__ import annotations
import argparse
import json
import os
import sys
sys.path.insert(0, os.path.dirname(__file__))
from model.registry import list_registered_platforms
PLATFORMS_DIR = "platforms"
def list_platforms() -> list[str]:
"""Every registered platform."""
return list_registered_platforms(PLATFORMS_DIR)
def main() -> None:
parser = argparse.ArgumentParser(allow_abbrev=False, description="List available platforms")
args = parser.parse_args()
from model.cliargs import work_from_repo_root
work_from_repo_root(args, parser, [])
platforms = list_platforms()
if not platforms:
print("No platform configs found", file=sys.stderr)
sys.exit(1)
github_output = os.environ.get("GITHUB_OUTPUT")
if github_output:
with open(github_output, "a") as f:
f.write(f"platforms={json.dumps(platforms)}\n")
else:
print(json.dumps(platforms))
if __name__ == "__main__":
from core.cli import run_cli
run_cli(main)