Files
psxrecomp/recompiler/tests/test_cli_project_packaging.py
Alexandros Mandravillis ff4be21c90 bios: add the SCPH-5500 and SCPH-5501 profiles
The v3.0 Japanese (SCPH-5500, 09/09/96) and US (SCPH-5501, 11/18/96)
retail BIOS images join SCPH-1001, SCPH-101 and SCPH-5552, so every v3.0
region (J, A, E) has a profile.

Both images match SCPH-1001 v2.2 byte for byte in the kernel,
ROM [0x80, 0x18000). SCPH-5501's reset vector is identical too; SCPH-5500's
differs in 24 bytes. The shell differs in both. So each profile is
SCPH1001.toml with its own identity (name, id, rom, sha256 pin, stem): the
copy windows and install slots are kernel properties and carry over
unchanged. The shell runs through the dirty-RAM interpreter, as for
SCPH5552.

Each image gets its own seed list, derived by the same rule as
phase2_ghidra_seeds_SCPH5552.json: the SCPH-1001 corpus filtered to seeds
whose 64-byte ROM window is identical in both images (534 kept, 569
dropped), plus the two architectural vectors and 6 A0/B0/C0 kernel-table
targets. The files carry only addresses, labels and rationales, plus the
SHA-256 of both ROMs.

- psx_bios_known_images.h: CRC-32 FF3EEB8C (SCPH-5500) and 8D8CB7E4
  (SCPH-5501), both 512 KiB. A build that does not link these backends
  builds one from the player's own dump as a loadable module, like
  SCPH-5552, and the netplay lobby can name the image.
- main_cli.cpp: map SCPH5500 / SCPH5501 dumps to their profiles.
- build_cli.py: package both profiles with the CLI framework.
- docs/BIOS_SELECTION.md: list them among the module-built images.
2026-10-01 09:28:13 +03:00

91 lines
3.9 KiB
Python

#!/usr/bin/env python3
"""Regression guards for the self-contained CLI project pipeline."""
from pathlib import Path
import sys
ROOT = Path(__file__).resolve().parents[2]
def require(source: str, needle: str, message: str) -> None:
if needle not in source:
raise AssertionError(message)
def main() -> int:
cli = (ROOT / "recompiler/src/main_cli.cpp").read_text(encoding="utf-8")
bios = (ROOT / "recompiler/src/main_bios.cpp").read_text(encoding="utf-8")
package = (ROOT / "tools/build_cli.py").read_text(encoding="utf-8")
new_project_cmake = (
ROOT / "tools/new_project_layout/templates/CMakeLists.txt.in"
).read_text(encoding="utf-8")
require(cli, 'bios_config = \\"psxrecomp/bios/{}\\"',
"generated game.toml does not name its BIOS profile")
require(cli, '"--config", fs::absolute(profile_destination).string()',
"CLI BIOS recompilation does not use the selected profile")
require(cli, '"--rom", options.bios.string()',
"CLI BIOS recompilation does not pass the user-selected ROM")
require(cli, '"--out-dir",',
"CLI BIOS recompilation does not override the generated output")
require(cli, 'framework_destination / "generated"',
"BIOS sources are not emitted where runtime.cmake discovers them")
require(cli, 'set(PSXRECOMP_BIOS_STEMS \\"{}\\"',
"generated CMake does not select the emitted BIOS backend")
require(cli, 'set(PSX_RECOMP_UI OFF CACHE BOOL \\"\\" FORCE)',
"self-contained CLI projects must not require a game-owned "
"recomp-ui checkout")
require(cli, 'PSXRecomp runtime is missing:',
"generated CLI project does not fail clearly when psxrecomp/ "
"is missing")
require(cli, 'git submodule update --init --recursive',
"generated CLI project missing-runtime error lacks the git "
"submodule recovery command")
require(cli, '$RuntimeCMake = Join-Path $Root',
"generated PowerShell build script lacks a runtime.cmake "
"preflight")
require(cli, '[ ! -f \\"$ROOT/psxrecomp/runtime/runtime.cmake\\" ]',
"generated shell build script lacks a runtime.cmake preflight")
require(new_project_cmake, 'PSXRecomp runtime is missing:',
"new-project-layout CMake template does not fail clearly when "
"psxrecomp/ is missing")
require(new_project_cmake, 'git submodule update --init --recursive',
"new-project-layout missing-runtime error lacks the git "
"submodule recovery command")
copy_pos = cli.find('fmt::print("[1/4] Copying build framework')
game_pos = cli.find('fmt::print("[2/4] Recompiling game executable')
if copy_pos < 0 or game_pos < 0 or copy_pos >= game_pos:
raise AssertionError(
"framework/profile must be copied before game recompilation")
for profile in (
"OpenBIOS.toml", "SCPH1001.toml",
"SCPH101.toml", "SCPH5500.toml", "SCPH5501.toml",
"SCPH5552.toml"):
require(package, f'"{profile}"',
f"CLI package omits BIOS profile {profile}")
require(package, 'shutil.copy2(ROOT / ".gitignore", framework)',
"packaged framework lacks the project-root marker used by profiles")
require(package, 'ROOT / "bios" / "openbios.bin"',
"packaged framework omits the redistributable OpenBIOS image")
require(package, 'ROOT / "bios" / "OpenBIOS.LICENSE"',
"packaged framework omits the OpenBIOS license")
require(bios, 'a == "--rom"',
"psxrecomp-bios config mode lacks the ROM override")
require(bios, 'a == "--out-dir"',
"psxrecomp-bios config mode lacks the output override")
print("PASS: CLI profiles, stage order, BIOS overrides, and UI isolation agree")
return 0
if __name__ == "__main__":
try:
sys.exit(main())
except AssertionError as exc:
print(f"FAIL: {exc}")
sys.exit(1)