mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-25 18:05:12 -04:00
bf5995a427
test_window_fullscreen.cpp is a separate test program with its own main(). It includes SDL_main.h and is built with SDL_MAIN_HANDLED. The single-owner guard sdl3_main_single_include counts every file under runtime/tests, so it has failed since that test was added. Name the file as a stand-alone program. Every other file under runtime/src, runtime/include and runtime/tests is still held to the one-owner rule.
55 lines
1.8 KiB
Python
55 lines
1.8 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>"
|
|
# Stand-alone test programs with their own main(). Each is a separate
|
|
# executable built with SDL_MAIN_HANDLED, so it never shares a link with
|
|
# main.cpp's entry point.
|
|
STANDALONE_TEST_PROGRAMS = {"runtime/tests/test_window_fullscreen.cpp"}
|
|
|
|
|
|
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:
|
|
rel = path.relative_to(ROOT).as_posix()
|
|
if rel not in STANDALONE_TEST_PROGRAMS:
|
|
owners.append(rel)
|
|
|
|
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)
|