runtime: accept prebuilt XMA2 decoder via -DLEONIDA_XMA2_DECODER_LIB (BUILD-XMA2-PREBUILT-LIB) #1491

Manually merged
github merged 2 commits from gh-pr/1491/head into gh-pr/1491/base 2026-11-26 09:53:54 +00:00
Owner

@⁠madhyn on GitHub · 2026-11-25 01:43 UTC · original
madhyn:feat/xma2-prebuilt-lib → main · +219 −33 · 5 files · 2 commits · merged 2026-11-25 02:00 UTC

Claimed in the coordination issue as: BUILD-XMA2-PREBUILT-LIB (claim)

What and why

Allows passing a prebuilt leonida_xma2_decoder.lib to CMake via -DLEONIDA_XMA2_DECODER_LIB=<path>, skipping cargo at configure time:

  • Problem: On Linux cross-builds (clang-cl + xwin), distribution Rust packages (for example Arch Linux's rust package) typically omit rust-std for x86_64-pc-windows-msvc. runtime/CMakeLists.txt unconditionally invoked cargo build --target x86_64-pc-windows-msvc, failed with a warning, and silently produced a runtime whose XMA2 voices output silence — even when the user had already cross-compiled leonida_xma2_decoder.lib with a matching Windows-MSVC sysroot. It also prevented offline / zero-configure-time-Cargo builds from reusing an existing static library (complementing #995).
  • Changes:
    • runtime/cmake/xma2_decoder.cmake: adds leonida_resolve_prebuilt_xma2_decoder() (kept in its own module so cmake -P can test it directly, matching runtime/cmake/vulkan_headers_missing.cmake). Resolves absolute or build-relative paths (including spaces) and raises FATAL_ERROR if a non-empty value does not point to an existing file, rather than falling back silently to muted audio.
    • runtime/CMakeLists.txt: adds the LEONIDA_XMA2_DECODER_LIB cache filepath variable; when set, bypasses find_program(LEONIDA_CARGO cargo) and execute_process(... cargo build ...) and imports the supplied library with the same LEONIDA_HAVE_XMA2_DECODER=1 and Windows SDK link contract (including synchronization). When unset, preserves the existing cargo configure path unchanged.
    • runtime/xma_decoder/README.md and docs/linux.md: document -DLEONIDA_XMA2_DECODER_LIB=<path> and the Linux x86_64-pc-windows-msvc target requirement.
    • tests/test_cmake_xma2_prebuilt.py: unit tests exercising runtime/cmake/xma2_decoder.cmake via cmake -P (empty, absolute, relative, spaces, missing file, directory) plus CMakeLists wiring checks.

Overlaps: #995 edits the same XMA2 block in runtime/CMakeLists.txt and runtime/xma_decoder/README.md (opt-in flag for configure-time Cargo); the two changes are complementary and merge cleanly in either order.

Tested

Arch Linux (7.3.5-arch1-1), clang-cl 23.1.5 + xwin SDK 10.0.26100, CMake + Ninja, GCC 16.2.1, Wine 11.22 (Staging), Python 3.14:

  • python3 -I scripts/check_no_game_data.py runtime/cmake/xma2_decoder.cmake runtime/CMakeLists.txt runtime/xma_decoder/README.md docs/linux.md tests/test_cmake_xma2_prebuilt.py: pass
  • python3 -I tests/test_cmake_xma2_prebuilt.py -v: 7/7 passed (cmake -P runs + CMakeLists wiring check)
  • tests/test_text_write_line_endings.py, tests/test_cmake_vulkan_missing.py, tests/test_cmake_translator_deps.py, tests/test_acphal_abi.py, tests/test_ci_registration.py, and all tests/test_docs_*.py + tests/test_i18n_index.py: all passed
  • Native Linux configure/build (cmake -S runtime -B ... -G Ninja) + ctest -R "^(root_signature|host_cpu)$": 2/2 passed
  • Windows cross-build (clang-cl-xwin.cmake) with a stub failing cargo (exit 99) first on PATH:
    • -DLEONIDA_XMA2_DECODER_LIB=/nonexistent/leonida_xma2_decoder.lib: configure failed with FATAL_ERROR naming LEONIDA_XMA2_DECODER_LIB
    • -DLEONIDA_XMA2_DECODER_LIB=<prebuilt leonida_xma2_decoder.lib> -DLEONIDA_REQUIRE_XMA2_DECODER=ON: configured in 1.5 s without invoking cargo, built acphal_test.exe and gta6rt.exe cleanly
    • wine acphal_test.exe: 170 checks, 0 failures (including non-silent Rust XMA2 PCM decode)

GPUs tested: n/a (build-system and documentation change; audio/runtime link verified under Wine 11.22 on Arch Linux with RTX 3060 Ti driver 615.78.08)

AI-assisted: yes

Checklist

  • Based on current main (5a5df8e0b) and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • Not a shader translator rule (docs/design.md contract table n/a).
**@⁠madhyn** on GitHub · 2026-11-25 01:43 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1491) `madhyn:feat/xma2-prebuilt-lib` → `main` · +219 −33 · 5 files · 2 commits · merged 2026-11-25 02:00 UTC Claimed in the coordination issue as: BUILD-XMA2-PREBUILT-LIB ([claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)) ### What and why Allows passing a prebuilt `leonida_xma2_decoder.lib` to CMake via `-DLEONIDA_XMA2_DECODER_LIB=<path>`, skipping `cargo` at configure time: - **Problem:** On Linux cross-builds (`clang-cl` + `xwin`), distribution Rust packages (for example Arch Linux's `rust` package) typically omit `rust-std` for `x86_64-pc-windows-msvc`. `runtime/CMakeLists.txt` unconditionally invoked `cargo build --target x86_64-pc-windows-msvc`, failed with a warning, and silently produced a runtime whose XMA2 voices output silence — even when the user had already cross-compiled `leonida_xma2_decoder.lib` with a matching Windows-MSVC sysroot. It also prevented offline / zero-configure-time-Cargo builds from reusing an existing static library (complementing #995). - **Changes:** - `runtime/cmake/xma2_decoder.cmake`: adds `leonida_resolve_prebuilt_xma2_decoder()` (kept in its own module so `cmake -P` can test it directly, matching `runtime/cmake/vulkan_headers_missing.cmake`). Resolves absolute or build-relative paths (including spaces) and raises `FATAL_ERROR` if a non-empty value does not point to an existing file, rather than falling back silently to muted audio. - `runtime/CMakeLists.txt`: adds the `LEONIDA_XMA2_DECODER_LIB` cache filepath variable; when set, bypasses `find_program(LEONIDA_CARGO cargo)` and `execute_process(... cargo build ...)` and imports the supplied library with the same `LEONIDA_HAVE_XMA2_DECODER=1` and Windows SDK link contract (including `synchronization`). When unset, preserves the existing `cargo` configure path unchanged. - `runtime/xma_decoder/README.md` and `docs/linux.md`: document `-DLEONIDA_XMA2_DECODER_LIB=<path>` and the Linux `x86_64-pc-windows-msvc` target requirement. - `tests/test_cmake_xma2_prebuilt.py`: unit tests exercising `runtime/cmake/xma2_decoder.cmake` via `cmake -P` (empty, absolute, relative, spaces, missing file, directory) plus CMakeLists wiring checks. Overlaps: #995 edits the same XMA2 block in `runtime/CMakeLists.txt` and `runtime/xma_decoder/README.md` (opt-in flag for configure-time Cargo); the two changes are complementary and merge cleanly in either order. ### Tested Arch Linux (`7.3.5-arch1-1`), `clang-cl` 23.1.5 + `xwin` SDK `10.0.26100`, CMake + Ninja, GCC 16.2.1, Wine 11.22 (Staging), Python 3.14: - `python3 -I scripts/check_no_game_data.py runtime/cmake/xma2_decoder.cmake runtime/CMakeLists.txt runtime/xma_decoder/README.md docs/linux.md tests/test_cmake_xma2_prebuilt.py`: pass - `python3 -I tests/test_cmake_xma2_prebuilt.py -v`: **7/7 passed** (`cmake -P` runs + CMakeLists wiring check) - `tests/test_text_write_line_endings.py`, `tests/test_cmake_vulkan_missing.py`, `tests/test_cmake_translator_deps.py`, `tests/test_acphal_abi.py`, `tests/test_ci_registration.py`, and all `tests/test_docs_*.py` + `tests/test_i18n_index.py`: **all passed** - Native Linux configure/build (`cmake -S runtime -B ... -G Ninja`) + `ctest -R "^(root_signature|host_cpu)$"`: **2/2 passed** - Windows cross-build (`clang-cl-xwin.cmake`) with a stub failing `cargo` (`exit 99`) first on `PATH`: - `-DLEONIDA_XMA2_DECODER_LIB=/nonexistent/leonida_xma2_decoder.lib`: configure failed with `FATAL_ERROR` naming `LEONIDA_XMA2_DECODER_LIB` - `-DLEONIDA_XMA2_DECODER_LIB=<prebuilt leonida_xma2_decoder.lib> -DLEONIDA_REQUIRE_XMA2_DECODER=ON`: configured in 1.5 s without invoking `cargo`, built `acphal_test.exe` and `gta6rt.exe` cleanly - `wine acphal_test.exe`: **170 checks, 0 failures** (including non-silent Rust XMA2 PCM decode) GPUs tested: n/a (build-system and documentation change; audio/runtime link verified under Wine 11.22 on Arch Linux with RTX 3060 Ti driver 615.78.08) AI-assisted: yes ### Checklist - [x] Based on current `main` (`5a5df8e0b`) and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (`CONTRIBUTING.md`), including in logs or reports quoted here. - [x] Not a shader translator rule (`docs/design.md` contract table n/a).
Configure checks only that the file passed with -DLEONIDA_XMA2_DECODER_LIB
exists, not which source, version or target it was built from. Say so, and
give the command that builds the library from this checkout's
runtime/xma_decoder for x86_64-pc-windows-msvc, where it lands, that it
needs only the Rust target (so it works on Linux), that the option stops
CMake from rebuilding the decoder after source changes, and that a
relative path given with -D is resolved against the directory CMake runs in.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:53:53 +00:00
github manually merged commit 46e078824d into gh-pr/1491/base 2026-11-26 09:53:54 +00:00
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 02:00 UTC · original

Merged. Thanks, @⁠madhyn: this is a useful escape hatch for cross-builds, and the cargo path is unchanged when the option is unset.

  • Claim: BUILD-XMA2-PREBUILT-LIB was posted at 01:40 UTC, three minutes before this PR, and is unedited. Nobody else claimed a prebuilt decoder.
  • I added one docs commit before merging (46e078824): configure checks only that the file exists, not which source, version or target it was built from, so runtime/xma_decoder/README.md now says to build the library yourself from this checkout, gives the cargo build ... --release --locked --target x86_64-pc-windows-msvc command and where the library lands, and says that with the option set CMake no longer rebuilds the decoder after source changes. docs/linux.md points to it.
  • A correction to the description: a relative path given with -D is made absolute by CMake against the directory it runs in, so the build-folder resolution in the helper only applies to values set some other way. The README now says to pass an absolute path.
  • Checked, configured both ways:
    • without the option, the configure output and CMakeCache.txt are identical to main's;
    • in a clang-cl cross-build with a library built from this checkout, configure printed "Using prebuilt Rust XMA2 decoder", a failing cargo placed first on PATH was never called, and acphal_test linked against the library;
    • a missing path stops configure with an error naming the variable.
  • Tests: tests/test_cmake_xma2_prebuilt.py passes 7 of 7 (and fails 7 of 7 on main's tree); the docs tests, test_text_write_line_endings, test_ci_registration and check_no_game_data.py on the changed files pass.
  • CI did not run on this PR (the workflows were waiting for approval).
  • Heads-up: #995 changes the same block of runtime/CMakeLists.txt and runtime/xma_decoder/README.md, so it now needs a merge of main; the two don't merge cleanly in either order.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠aslan2142** on GitHub · 2026-11-25 02:00 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1491#issuecomment-7150204457) Merged. Thanks, @⁠madhyn: this is a useful escape hatch for cross-builds, and the cargo path is unchanged when the option is unset. - **Claim:** `BUILD-XMA2-PREBUILT-LIB` was posted at 01:40 UTC, three minutes before this PR, and is unedited. Nobody else claimed a prebuilt decoder. - **I added one docs commit before merging** (`46e078824`): configure checks only that the file exists, not which source, version or target it was built from, so `runtime/xma_decoder/README.md` now says to build the library yourself from this checkout, gives the `cargo build ... --release --locked --target x86_64-pc-windows-msvc` command and where the library lands, and says that with the option set CMake no longer rebuilds the decoder after source changes. `docs/linux.md` points to it. - **A correction to the description:** a relative path given with `-D` is made absolute by CMake against the directory it runs in, so the build-folder resolution in the helper only applies to values set some other way. The README now says to pass an absolute path. - **Checked, configured both ways:** - without the option, the configure output and `CMakeCache.txt` are identical to `main`'s; - in a clang-cl cross-build with a library built from this checkout, configure printed "Using prebuilt Rust XMA2 decoder", a failing `cargo` placed first on `PATH` was never called, and `acphal_test` linked against the library; - a missing path stops configure with an error naming the variable. - **Tests:** `tests/test_cmake_xma2_prebuilt.py` passes 7 of 7 (and fails 7 of 7 on `main`'s tree); the docs tests, `test_text_write_line_endings`, `test_ci_registration` and `check_no_game_data.py` on the changed files pass. - **CI did not run on this PR** (the workflows were waiting for approval). - **Heads-up:** #995 changes the same block of `runtime/CMakeLists.txt` and `runtime/xma_decoder/README.md`, so it now needs a merge of `main`; the two don't merge cleanly in either order. AI-assisted (Claude Code, Claude Opus 5.5).
This discussion has been locked. Commenting is limited to contributors.
No description provided.