Build variants

SDL3, Vulkan and FFmpeg are mandatory for the NX runtime, including when running with -H. There are no renderer or media-decoding disable options. Tools-only and GNUABI-only builds do not need them.

Persistent per-build-dir options (POSIX examples):

cmake --preset default -B build -DSNX_FFMPEG_ASM=OFF && cmake --build build

Test options, all OFF by default. One that is on without BUILD_TESTING=ON stops the configure, as nothing would build it:

With Unicorn (its header and library, found or given with -DSNX_UNICORN_INCLUDE_DIR and -DSNX_UNICORN_LIBRARY; Python's wheel of unicorn 2.1.4 has both, in its include and lib/libunicorn.so.2), the tests labelled unicorn run the code that the native back ends make for the other machines against the recorded ends (test-references' recompiler_backends/), and their A32 and Thumb blocks (arm_<machine>_vector and its like, with SNX_TEST_ARM_DIFF) against Unicorn's own ARM core (ctest -L unicorn, ctest -L rv64 for one machine). CI's job Linux (x86_64, other machines under Unicorn) runs them in every pull request, run by hand and version's tag, as all of its tests, and fails where a machine ran none (scripts/unicorn-tests.py). PowerPC64's are skipped: Unicorn 2.1.4 as it is released does not hold the MSR of a 64-bit PowerPC.

The random A32 and Thumb blocks of the profiles and memories no Unicorn test draws (the Cortex-A9's, the ARM11's, the ARM946E-S's and the ARM7TDMI's, hosted and checked memory, the ARM7TDMI's trace), arm_<machine>_<mode>, are held to LLVM -O0's results as test-references' arm/ keeps them, recorded while the build had LLVM: a hash a block over its states (arm_x64.c's --frozen, the file's first blocks on the machines under Unicorn). python3 tests/arm_frozen.py verify build/tests/snx-test-arm-x64 --out <test-references>/arm runs every file and says what each covers; a change to how arm_x64.c draws its blocks bumps its FROZEN_GENERATOR, and the files need another reference.

The tests labelled census (ctest -L census -V) recompile five whole programs that they make: a Switch game of a word of each A64 instruction, the same with a Switch 2's NPDM, an NRO of it, a 32-bit Switch game of each A32 and Thumb instruction, and a 3DS game of the ARM11's. Each prints how many of its functions or blocks this machine's native back end made, and fails where it left any, naming its address and its word. On a machine with no native back end they are skipped, saying so. CI's Linux, Windows and macOS jobs and its cross builds print the five counts, and fail where one is missing (scripts/recompile-census.py).

# Build without the GUI launcher; SDL3 remains required by the runtime:
cmake --preset default -B build/headless-vk -DSNX_BUILD_GUI=OFF -DSNX_DEPLOY=OFF &&
cmake --build build/headless-vk
# Run Vulkan without a display server, a surface or a swapchain:
./build/headless-vk/scarletnx "Game.xci" -H

cmake --preset windows-cross && cmake --build --preset windows-cross
# -> build/windows-cross/scarletnx.exe; requires llvm-mingw on PATH

All NX builds use SDL3 and support -H at runtime. Omit the flag to run with a window. Software Vulkan / lavapipe setup.

Offscreen integration test, with an installed Vulkan 1.3 ICD (lavapipe works):

cmake --preset default -B build/headless-vk -DSNX_BUILD_GUI=OFF \
  -DSNX_DEPLOY=OFF -DBUILD_TESTING=ON -DSNX_TEST_VULKAN=ON && cmake --build build/headless-vk
# Set VK_DRIVER_FILES to your lavapipe manifest to force CPU rendering.
ctest --test-dir build/headless-vk -R vulkan_headless --output-on-failure
# the same with the validation layer
(cd build/headless-vk && src/nx/snx-test-vulkan -H --vk-validation=1)

The test uses synthetic pixels, not a game. It checks offscreen submissions, frame recycling, cropping, readback hashes and PPM contents without WSI. Validation requires the Khronos validation layer to be installed. It takes the runtime's settings as --KEY=VALUE (--vk-memory=2, --memory-traps=2) and stops on any other argument. SNX_TEST_VULKAN is off by default so ordinary unit tests do not require an ICD.


Made from docs/dev/build.md at 69237645142c. GPL-3.0-or-later.