diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a47e3304..b9870d64 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -139,7 +139,7 @@ cmake --build recompiler/build cd recompiler/build && ctest --output-on-failure ``` -37 tests, under five seconds, no BIOS dump or disc image required. See +38 tests, under five seconds, no BIOS dump or disc image required. See [`docs/TESTING.md`](docs/TESTING.md) for running individual tests, what the suite covers, and the three known-failing tests that are deliberately not registered. diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 7e2f2c28..1d09623b 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -135,7 +135,7 @@ After step 1 above — no BIOS or disc needed — verify the tree is sane: cd recompiler/build && ctest --output-on-failure ``` -37 tests, under five seconds. See [`TESTING.md`](TESTING.md). +38 tests, under five seconds. See [`TESTING.md`](TESTING.md). On Windows with MSVC or plain MinGW makefiles, swap `-G Ninja` for your generator (e.g. `-G "Unix Makefiles"`); everything else is identical. diff --git a/docs/TESTING.md b/docs/TESTING.md index c8fb0be4..2fe84b13 100644 --- a/docs/TESTING.md +++ b/docs/TESTING.md @@ -8,7 +8,7 @@ cmake --build recompiler/build cd recompiler/build && ctest --output-on-failure ``` -That is the whole thing. 37 tests, under 5 seconds, and it needs **no BIOS dump, +That is the whole thing. 38 tests, under 5 seconds, and it needs **no BIOS dump, no disc image, and no generated code** — a plain recompiler build is enough. This is the check to run before opening a PR. diff --git a/recompiler/CMakeLists.txt b/recompiler/CMakeLists.txt index e3fb993e..52202b0f 100644 --- a/recompiler/CMakeLists.txt +++ b/recompiler/CMakeLists.txt @@ -409,8 +409,9 @@ if(BUILD_TESTING) mod_controller_override overlay_candidate_capacity overlay_decodable_fallback - overlay_init_guard - vk_build_default + overlay_init_guard + sdl3_main_single_include + vk_build_default vk_color_self_barrier vk_command_buffer_batching vk_draw_area_batch_boundary diff --git a/runtime/include/psx_sdl.h b/runtime/include/psx_sdl.h index ef1ceb70..1749b46f 100644 --- a/runtime/include/psx_sdl.h +++ b/runtime/include/psx_sdl.h @@ -11,7 +11,6 @@ #define SDL_ENABLE_OLD_NAMES #define SDL_FUNCTION_POINTER_IS_VOID_POINTER #include -#include #ifndef SDL_WINDOW_SHOWN #define SDL_WINDOW_SHOWN 0 diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index 181cddcc..23e39501 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp @@ -72,6 +72,14 @@ extern "C" void psx_event_step_conservative_env_init(void); #include "launcher_profile.h" /* per-system variant profile (theme/caps bundle) */ #endif #include "psx_sdl.h" +#if defined(PSX_SDL3) +/* + * SDL_main.h is a single-header implementation in SDL3. Keep it in the one + * translation unit that defines main(); including it through psx_sdl.h makes + * every SDL-using source emit WinMain under MinGW. + */ +#include +#endif #include "psx_sdl_audio.h" #if defined(PSX_WEB) #include diff --git a/runtime/tests/test_sdl3_main_single_include.py b/runtime/tests/test_sdl3_main_single_include.py new file mode 100644 index 00000000..71a4ad2b --- /dev/null +++ b/runtime/tests/test_sdl3_main_single_include.py @@ -0,0 +1,45 @@ +#!/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 = "" + + +def main() -> int: + runtime = ROOT / "runtime" + owners = [] + for pattern in ("*.c", "*.cpp", "*.h"): + for path in runtime.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)