mirror of
https://github.com/RetroPortingToolKit/psxrecomp
synced 2026-10-25 18:05:12 -04:00
Fix zero-BIOS MSVC registry build
This commit is contained in:
@@ -537,6 +537,9 @@ if(BUILD_TESTING)
|
||||
add_test(NAME cdrom_lid_integration_test
|
||||
COMMAND ${Python3_EXECUTABLE}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_cdrom_lid_integration.py)
|
||||
add_test(NAME bios_registry_zero_entry_guard_test
|
||||
COMMAND ${Python3_EXECUTABLE}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/tests/test_bios_registry_zero_entry.py)
|
||||
endif()
|
||||
|
||||
# Full card protocol regression: read, write, address echo, per-slot state,
|
||||
|
||||
@@ -667,6 +667,15 @@ else()
|
||||
list(LENGTH _psxrt_bios_linked _psxrt_bios_count)
|
||||
endif()
|
||||
|
||||
# ISO C requires at least one initializer. A setup host can intentionally have
|
||||
# zero linked BIOS backends, so give the generated array one unused null entry
|
||||
# while keeping its public count at zero. MSVC 19.44 otherwise crashes with
|
||||
# C1001 in CloseTypeServerPDB when it compiles an empty initializer list.
|
||||
if(NOT _psxrt_registry_entries)
|
||||
set(_psxrt_registry_entries " 0, /* unused: registry count is zero */
|
||||
")
|
||||
endif()
|
||||
|
||||
# Registry of the compiled-in backends, in preference order. Generated so the
|
||||
# stem list stays the single source of truth.
|
||||
set(_psxrt_registry_c "${CMAKE_BINARY_DIR}/psx_bios_registry.c")
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Keep setup-host BIOS registry generation valid ISO C."""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
RUNTIME_CMAKE = (ROOT / "runtime" / "runtime.cmake").read_text(encoding="utf-8")
|
||||
|
||||
guard = "if(NOT _psxrt_registry_entries)"
|
||||
sentinel = 'set(_psxrt_registry_entries " 0, /* unused: registry count is zero */'
|
||||
writer = 'set(_psxrt_registry_c "${CMAKE_BINARY_DIR}/psx_bios_registry.c")'
|
||||
|
||||
assert guard in RUNTIME_CMAKE
|
||||
assert sentinel in RUNTIME_CMAKE
|
||||
assert RUNTIME_CMAKE.index(guard) < RUNTIME_CMAKE.index(writer)
|
||||
|
||||
print("zero-entry BIOS registry guard passed")
|
||||
Reference in New Issue
Block a user