Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ jobs:
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DLEONIDA_D3D12_SHIM_TESTS=ON
-DLEONIDA_REQUIRE_VULKAN=ON
-DLEONIDA_REQUIRE_XMA2_DECODER=ON
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache
-DCMAKE_POLICY_DEFAULT_CMP0141=NEW
-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded
Expand Down
44 changes: 44 additions & 0 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,44 @@ if(WIN32 AND LEONIDA_BUILD_WINDOWS_RUNTIME)
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>"
)

# Rust XMA2 decoder (runtime/xma_decoder), built at configure time when cargo is on PATH.
# Without it (or if that build fails) the runtime still builds and XMA voices output silence.
option(LEONIDA_REQUIRE_XMA2_DECODER "Fail configure if the Rust XMA2 decoder is unavailable" OFF)
find_program(LEONIDA_CARGO cargo)
if(LEONIDA_CARGO)
# Cargo's host (or configured default target) can differ from the runtime's MSVC ABI.
set(_xma_target x86_64-pc-windows-msvc)
set(_xma_target_dir ${CMAKE_BINARY_DIR}/xma_decoder)
set(_xma_lib ${_xma_target_dir}/${_xma_target}/release/leonida_xma2_decoder.lib)
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
${CMAKE_CURRENT_SOURCE_DIR}/xma_decoder/Cargo.toml
${CMAKE_CURRENT_SOURCE_DIR}/xma_decoder/Cargo.lock
${CMAKE_CURRENT_SOURCE_DIR}/xma_decoder/src/lib.rs)
execute_process(
COMMAND ${LEONIDA_CARGO} build --release --locked --target ${_xma_target}
--manifest-path ${CMAKE_CURRENT_SOURCE_DIR}/xma_decoder/Cargo.toml
--target-dir ${_xma_target_dir}
TIMEOUT 120
RESULT_VARIABLE _xma_result)
if(_xma_result STREQUAL "0" AND EXISTS ${_xma_lib})
add_library(leonida_xma2_decoder STATIC IMPORTED)
# Link Rust's Windows SDK dependencies. CMake's C++ target selects its own CRT
# (/MD or /MDd); the C ABI keeps allocation and deallocation on the same side.
set_target_properties(leonida_xma2_decoder PROPERTIES
IMPORTED_LOCATION ${_xma_lib}
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_CURRENT_SOURCE_DIR}/xma_decoder
INTERFACE_COMPILE_DEFINITIONS LEONIDA_HAVE_XMA2_DECODER=1
INTERFACE_LINK_LIBRARIES "kernel32;ntdll;userenv;ws2_32;dbghelp")
else()
message(WARNING "cargo build of runtime/xma_decoder failed: XMA voices will be silent")
endif()
else()
message(STATUS "cargo not found: runtime/xma_decoder not built, XMA voices will be silent")
endif()
if(LEONIDA_REQUIRE_XMA2_DECODER AND NOT TARGET leonida_xma2_decoder)
message(FATAL_ERROR "LEONIDA_REQUIRE_XMA2_DECODER is enabled, but the Rust XMA2 decoder is unavailable")
endif()

add_executable(gta6rt
src/main.cpp
src/host_cpu.cpp
Expand Down Expand Up @@ -250,6 +288,11 @@ if(WIN32 AND LEONIDA_BUILD_WINDOWS_RUNTIME)
target_compile_options(acphal_test PRIVATE /W4 /permissive- /utf-8)
target_link_options(acphal_test PRIVATE /OPT:NOREF)

if(TARGET leonida_xma2_decoder)
target_link_libraries(gta6rt PRIVATE leonida_xma2_decoder)
target_link_libraries(acphal_test PRIVATE leonida_xma2_decoder)
endif()

# The Zen 2 instructions a desktop CPU may lack (src/cpu_emulation.h): decoded, emulated on a CONTEXT, and run for
# real with the #UD handler installed, so an Intel host takes the emulated path and an AMD one the native path.
add_executable(cpu_emulation_test test/cpu_emulation_test.cpp)
Expand Down Expand Up @@ -1162,6 +1205,7 @@ if(BUILD_TESTING)
endif()
if(WIN32 AND TARGET acphal_test)
add_test(NAME acphal COMMAND acphal_test)
add_test(NAME acphal_noncached_only COMMAND acphal_test --noncached-only)
endif()
if(WIN32 AND TARGET cpu_emulation_test)
add_test(NAME cpu_emulation COMMAND cpu_emulation_test)
Expand Down
Loading
Loading