Files
psxrecomp/runtime/tests/test_sdl3_main_single_include.py
T
Matthew Stanley ec4c91cd94 runtime: GP0 source key and overlay_region_floor follow the 8 MiB window
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-26 08:03:58 -07:00

49 lines
1.5 KiB
Python

#!/usr/bin/env python3
"""Keep SDL3's single-header entry-point implementation in main.cpp only."""
from pathlib import Path
import sys
ROOT = Path(__file__).resolve().parents[2]
SDL_MAIN_HEADER = "<SDL3/SDL_main.h>"
def main() -> int:
runtime = ROOT / "runtime"
owners = []
# Sources only: a build tree under runtime/ (the documented runtime/build
# layout) holds generated binary-ish headers such as vk_shaders_spv.h.
for tree in ("src", "include", "tests"):
for pattern in ("*.c", "*.cpp", "*.h"):
for path in (runtime / tree).rglob(pattern):
source = path.read_text(encoding="utf-8")
if SDL_MAIN_HEADER in source:
owners.append(path.relative_to(ROOT).as_posix())
if owners != ["runtime/src/main.cpp"]:
raise AssertionError(
"SDL_main.h must be included exactly once by runtime/src/main.cpp; "
f"found {owners}"
)
main_cpp = (runtime / "src/main.cpp").read_text(encoding="utf-8")
guard = (
"#if defined(PSX_SDL3)\n"
"/*\n"
" * SDL_main.h is a single-header implementation"
)
if guard not in main_cpp:
raise AssertionError("SDL_main.h include is no longer guarded by PSX_SDL3")
print("PASS: SDL3 entry-point implementation has one owner")
return 0
if __name__ == "__main__":
try:
sys.exit(main())
except AssertionError as exc:
print(f"FAIL: {exc}")
sys.exit(1)