Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a32958e
external_deps: add smart_copy
illwieckz Jun 25, 2026
bb88d3d
external_deps: do not copy WASI into WASI
illwieckz Jun 25, 2026
37f8e02
external_deps: better wasmtime copy
illwieckz Jun 25, 2026
ae48cbe
external_deps: better sdl3 copy
illwieckz Jun 25, 2026
20f665b
external_deps: better copy in extract()
illwieckz Jun 25, 2026
33100b4
external_deps: build naclruntime with CMake
illwieckz Jun 25, 2026
6891e9d
external_deps: make possible to reconfigure for a different target
illwieckz Jun 25, 2026
4f3413e
external_deps: make defaults resetable with setup_default()
illwieckz Jun 25, 2026
4ad556f
cmake,external_deps: expect loader be packaged with architecture suff…
illwieckz Jun 26, 2026
4d3751c
external_deps: repackage saigosdk
illwieckz Jun 25, 2026
cbb738b
cmake: use Saigo by default to compile NaCl binaries
illwieckz Jun 26, 2026
8319dc5
external_deps: build pkg-config as a native tool
illwieckz Jun 26, 2026
6bd9a8d
external_deps: build nasm as a native tool
illwieckz Jun 26, 2026
3c8ce70
external_deps: build jwasm as a native tool
illwieckz Jun 26, 2026
fb0fe16
cmake,framework: Append the architecture name to nacl_loader and nacl…
illwieckz Jun 26, 2026
72fa705
external_deps: upgrade sdl3
illwieckz Jun 26, 2026
9ed4e05
external_deps: upgrade zlib
illwieckz Jun 26, 2026
6dd9789
external_deps: upgrade nettle
illwieckz Jun 26, 2026
b300a70
external_deps: upgrade curl
illwieckz Jun 26, 2026
a638781
external_deps: upgrade glew
illwieckz Jun 26, 2026
8fd4515
external_deps: upgrade png
illwieckz Jun 26, 2026
53bb6cc
external_deps: upgrade jpeg
illwieckz Jun 26, 2026
ac7dfc4
external_deps: do not upgrade openal
illwieckz Jun 26, 2026
ef80519
external_deps: upgrade opus
illwieckz Jun 26, 2026
f15135e
external_deps: disable the GPU framework
illwieckz Jun 26, 2026
58c1eb2
external_deps: make possible to loop the cmake build
illwieckz Jun 27, 2026
3b09634
external_deps: extract platform components
illwieckz Jun 25, 2026
a009364
external_deps: add macos-arm64-default
illwieckz Jun 26, 2026
d85946a
external_deps: rework the cmake toolchain configuration
illwieckz Jun 27, 2026
4c87988
external_deps: rework the macos configuration
illwieckz Jun 27, 2026
776f8e1
external_deps: deduplicate files with hardlinks before making the tar…
illwieckz Jun 27, 2026
2e207cb
external_deps: tell xz to use extreme compression
illwieckz Jun 27, 2026
3f95c9b
external_deps: make EXE_EXT reusable
illwieckz Jun 25, 2026
69bb415
cmake: download macos-arm64 deps archive
illwieckz Jun 27, 2026
5413442
external_deps: deduplicate nacl from pnacl copy code
illwieckz Jun 27, 2026
8f02fea
external_deps: provide a reusable framework for building native tools…
illwieckz Jun 26, 2026
72a70be
ci/azure: macos-arm64
illwieckz Jun 27, 2026
846bd12
cmake: fix DaemonNaclHost
illwieckz Jun 27, 2026
38a6439
yokai: update qprocessordetection.h from Qt upstream and recognize lo…
illwieckz Jun 29, 2026
2835762
yokai: rework of the architecture and system detection
illwieckz Jun 29, 2026
f7534eb
yokai: detect host architecture
illwieckz Jun 29, 2026
b137c1d
cmake: use box64 on loong64
illwieckz Jun 29, 2026
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
26 changes: 8 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ else()
endif()

# Dependencies version, this must match the number in external_deps/build.sh
set(DEPS_VERSION 11)
set(DEPS_VERSION 12)

option(USE_EXTERNAL_DEPS "Download or reuse dependencies from EXTERNAL_DEPS_DIR (mandatory for building and running NaCl .nexe binaries)." ON)

Expand Down Expand Up @@ -220,17 +220,7 @@ if (USE_EXTERNAL_DEPS AND NOT YOKAI_TARGET_SYSTEM_NACL)
set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64 i686)
elseif (YOKAI_TARGET_SYSTEM_MACOS)
set(DEPS_SYSTEM macos)
set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64)

if (YOKAI_TARGET_ARCH_ARM64)
set(DEPS_ARCH amd64)

set_deps_dir()

if (NOT EXISTS ${DEPS_DIR})
set(DEFAULT_USE_EXTERNAL_DEPS_LIBS OFF)
endif()
endif()
set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64 arm64)
elseif (YOKAI_TARGET_SYSTEM_LINUX)
set(DEPS_SYSTEM linux)
set(SUPPORTED_${DEPS_SYSTEM}_ARCH amd64 i686 arm64 armhf)
Expand Down Expand Up @@ -973,8 +963,8 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER
# The NaCl loader and IRT are required to load .nexe files
add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${DEPS_DIR}/nacl_loader${CMAKE_EXECUTABLE_SUFFIX}
${FULL_OUTPUT_DIR}/nacl_loader${CMAKE_EXECUTABLE_SUFFIX}
${DEPS_DIR}/nacl_loader-${DAEMON_NACL_ARCH_NAME}${CMAKE_EXECUTABLE_SUFFIX}
${FULL_OUTPUT_DIR}/nacl_loader-${DAEMON_NACL_ARCH_NAME}${CMAKE_EXECUTABLE_SUFFIX}
)

add_custom_command(TARGET runtime_deps PRE_BUILD
Expand All @@ -986,8 +976,8 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER
# Linux uses a bootstrap program to reserve address space
if (YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY)
if (YOKAI_TARGET_ARCH_ARM64)
add_executable(nacl_helper_bootstrap-armhf tools/nacl_helper_bootstrap-armhf/nacl_helper_bootstrap-armhf.cpp)
add_dependencies(runtime_deps nacl_helper_bootstrap-armhf)
add_executable(nacl_helper_bootstrap-ldarmhf tools/nacl_helper_bootstrap-ldarmhf/nacl_helper_bootstrap-ldarmhf.cpp)
add_dependencies(runtime_deps nacl_helper_bootstrap-ldarmhf)

add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory
Expand All @@ -1003,8 +993,8 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER

add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${DEPS_DIR}/nacl_helper_bootstrap
${FULL_OUTPUT_DIR}/nacl_helper_bootstrap
${DEPS_DIR}/nacl_helper_bootstrap-${DAEMON_NACL_ARCH_NAME}
${FULL_OUTPUT_DIR}/nacl_helper_bootstrap-${DAEMON_NACL_ARCH_NAME}
)
endif()

Expand Down
20 changes: 16 additions & 4 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,19 @@ pr:
- .gitmodules

jobs:
- job: Mac
- job: macOS
pool:
vmImage: 'macOS-15'
strategy:
matrix:
AppleClang amd64:
MACOS_ARCH: x86_64
MACOS_VERSION: 10.14
TEST: true
AppleClang arm64:
MACOS_ARCH: arm64
MACOS_VERSION: 11.7
TEST: false
steps:
- bash: |
set -e
Expand Down Expand Up @@ -56,12 +66,14 @@ jobs:
cmake --version
export CFLAGS='-Wno-c++14-extensions'
export CXXFLAGS='-Wno-c++14-extensions'
cmake -Wdev -Wdeprecated -DUSE_PRECOMPILED_HEADER=0 -DUSE_WERROR=1 -DBE_VERBOSE=1 -DCMAKE_BUILD_TYPE=Release -DBUILD_DUMMY_APP=1 -DBUILD_DUMMY_GAMELOGIC=1 -DBUILD_TESTS=1 -H. -Bbuild
cmake -Wdev -Wdeprecated -DCMAKE_OSX_ARCHITECTURES=${MACOS_ARCH} -DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOS_VERSION} -DPREFER_EXTERNAL_LIBS=OFF -DUSE_PRECOMPILED_HEADER=0 -DUSE_WERROR=1 -DBE_VERBOSE=1 -DCMAKE_BUILD_TYPE=Release -DBUILD_DUMMY_APP=1 -DBUILD_DUMMY_GAMELOGIC=1 -DBUILD_TESTS=1 -H. -Bbuild
cmake --build build -- -j`sysctl -n hw.logicalcpu`
displayName: 'Build'
- bash: |
set -e
build/test-ttyclient -pakpath pkg -set fs_basepak daemon -set vm.cgame.type 3
if "${TEST}"; then
set -e
build/test-ttyclient -pakpath pkg -set fs_basepak daemon -set vm.cgame.type 3
fi
displayName: 'Test'

- job: Linux
Expand Down
2 changes: 1 addition & 1 deletion cmake/DaemonNacl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# Native client

option(USE_NACL_SAIGO "Use Saigo toolchain to build NaCl executables" OFF)
option(USE_NACL_SAIGO "Use the Saigo toolchain to build NaCl executables" ON)

if (YOKAI_TARGET_SYSTEM_NACL)
# Build nexe binary.
Expand Down
43 changes: 24 additions & 19 deletions cmake/DaemonNaclHost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

function(daemon_detect_nacl_arch)
set(arch_name "${YOKAI_TARGET_ARCH_NAME}")
set(nacl_arch "${arch_name}")
set(target_arch "${YOKAI_TARGET_ARCH_NAME}")
set(nacl_arch "${target_arch}")

if (YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY OR YOKAI_TARGET_SYSTEM_XDG_COMPATIBILITY)
set(armhf_usage "arm64;armel")
if ("${arch_name}" IN_LIST armhf_usage)
# Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch.
# The nexe is system agnostic so there should be no difference with armel.
set(nacl_arch "armhf")
set(armhf_usage "arm64" "armel")
set(box64_usage "ppc64el" "riscv64" "loong64")

set(box64_usage ppc64el riscv64)
if ("${arch_name}" IN_LIST box64_usage)
if ("${target_arch}" IN_LIST armhf_usage)
# Load 32-bit armhf nexe on 64-bit arm64 engine on Linux with multiarch.
# The nexe is system agnostic so there should be no difference with armel.
set(nacl_arch "armhf")
elseif ("${target_arch}" IN_LIST box64_usage)
option(DAEMON_NACL_BOX64_EMULATION "Use Box64 to emulate x86_64 NaCl loader on unsupported platforms" ON)
if (DAEMON_NACL_BOX64_EMULATION)
# Use Box64 to run x86_64 NaCl loader and amd64 nexe.
Expand All @@ -45,27 +45,32 @@ function(daemon_detect_nacl_arch)
add_definitions(-DDAEMON_NACL_BOX64_EMULATION)
endif()
endif()
endif()

elseif (DAEMON_TARGET_SYSTEM_MACOS)
if ("${arch_name}" STREQUAL "arm64")
elseif (YOKAI_TARGET_SYSTEM_MACOS)
if ("${target_arch}" STREQUAL "arm64")
# You can get emulated NaCl going like this:
# cp external_deps/macos-amd64-default_10/{nacl_loader,irt_core-amd64.nexe} build/
set(nacl_arch "amd64")
endif()
endif()

string(TOUPPER "${nacl_arch_name}" nacl_arch_name_upper)

# The DAEMON_NACL_ARCH_NAME variable contributes to the nexe file name.
set(DAEMON_NACL_ARCH_NAME "${nacl_arch}" PARENT_SCOPE)
set(DAEMON_NACL_ARCH_NAME_UPPER "${nacl_arch_upper}" PARENT_SCOPE)
string(TOUPPER "${nacl_arch}" nacl_arch_upper)

# NaCl runtime is only available on architectures that have a NaCl loader.
set(nacl_runtime_arch amd64 i686 armhf)
set(nacl_runtime_arch "amd64" "i686" "armhf")
if ("${nacl_arch}" IN_LIST nacl_runtime_arch)
message(STATUS "Detected NaCl architecture: ${nacl_arch}")

add_definitions(-DDAEMON_NACL_RUNTIME_ENABLED)
else()
set(nacl_arch "unknown")

message(STATUS "No NaCl architecture detected")
endif()

# The DAEMON_NACL_ARCH_NAME variable contributes to the nexe file name.
set(DAEMON_NACL_ARCH_NAME "${nacl_arch}" PARENT_SCOPE)

set(DAEMON_NACL_ARCH_NAME_UPPER "${nacl_arch_upper}" PARENT_SCOPE)
endfunction()

daemon_detect_nacl_arch()
Expand Down
141 changes: 128 additions & 13 deletions cmake/Yokai/Architecture.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,104 @@
# Architecture detection.
################################################################################

# When adding a new architecture, look at all the places YOKAI_TARGET_ARCH is used.
# When adding a new architecture, look at all the places YOKAI_HOST_ARCH
# and YOKAI_TARGET_ARCH are used.

option(USE_ARCH_INTRINSICS "Enable custom code using intrinsics functions or asm declarations" ON)
mark_as_advanced(USE_ARCH_INTRINSICS)

function(yokai_detect_arch)
function(yokai_detect_host_arch)
set(arch_name "unknown")

string(TOLOWER "${CMAKE_HOST_SYSTEM_PROCESSOR}" processor_lower)

foreach(name
"arm"
"arm64"
"i686"
"mipsel"
"ppc64"
"riscv64"
)
if ("${processor_lower}" STREQUAL "${name}")
set(arch_name "${processor_lower}")
endif()
endforeach()

if ("${arch_name}" STREQUAL "unknown")
set(ARCH_em64t "amd64")
set(ARCH_x86_64 "amd64")
set(ARCH_armv7l, "arm")
set(ARCH_armv6l, "arm")
set(ARCH_aarch64 "arm64")
set(ARCH_loongarch64, "loong64")
set(ARCH_ppc64le, "ppc64el")

foreach(name
"amd64"
"arm"
)
if ("${ARCH_${processor_lower}}" STREQUAL "${name}")
set(arch_name "${ARCH_${processor_lower}}")
endif()
endforeach()
endif()

if ("${arch_name}" STREQUAL "unknown")
if ("${processor_lower}")
message(WARNING "Undocumented host architecture: ${processor_lower}")
else()
message(WARNING "Undocumented host architecture")
endif()

set(arch_name "${processor_lower}")
endif()

string(TOUPPER "${arch_name}" arch_name_upper)

set(YOKAI_HOST_ARCH_NAME "${arch_name}" PARENT_SCOPE)
set(YOKAI_HOST_ARCH_NAME_UPPER "${arch_name_upper}" PARENT_SCOPE)

# Makes possible to do that in CMake code:
# > if (YOKAI_HOST_ARCH_AMD64)
set("YOKAI_HOST_ARCH_${arch_name_upper}" ON PARENT_SCOPE)

if ("${arch_name}" STREQUAL "unknown")
message(WARNING "Unknown host architecture: ${processor_lower}")

set(arch_name "${processor_lower}")
endif()

set(arm_CHILD
"armel"
"armhf"
)

foreach(name
"arm"
)
if ("${arch_name}" STREQUAL "${name}")
message(STATUS "Parent architecture: ${name}, can be ${AMBIGUOUS_${name}}")

foreach(child_name ${${name}_CHILD})
string(TOUPPER "${child_name}" child_name_upper)
set(YOKAI_HOST_ARCH_${child_name_upper}_PARENT ON PARENT_SCOPE)
endforeach()
endif()
endforeach()
endfunction()

function(yokai_detect_target_arch)
yokai_run_detection("TARGET" "ARCH" "Architecture.c" "")

set(YOKAI_TARGET_ARCH_NAME "${arch_name}" PARENT_SCOPE)
set(YOKAI_TARGET_ARCH_NAME_UPPER "${arch_name_upper}" PARENT_SCOPE)

message(STATUS "Detected target architecture: ${arch_name}")

add_definitions(-DYOKAI_ARCH_${arch_name_upper})

# Makes possible to do that in CMake code:
# > if (YOKAI_TARGET_ARCH_AMD64)
set("YOKAI_TARGET_ARCH_${arch_name_upper}" ON PARENT_SCOPE)
endfunction()

function(yokai_set_arch_intrinsics name)
Expand All @@ -50,9 +134,6 @@ function(yokai_set_arch_intrinsics name)
add_definitions(-DYOKAI_USE_ARCH_INTRINSICS_${name_upper})
endfunction()

option(USE_ARCH_INTRINSICS "Enable custom code using intrinsics functions or asm declarations" ON)
mark_as_advanced(USE_ARCH_INTRINSICS)

function(yokai_set_intrinsics)
if (USE_ARCH_INTRINSICS)
# Makes possible to do that in C++ code:
Expand All @@ -61,7 +142,6 @@ function(yokai_set_intrinsics)

# Makes possible to do that in C++ code:
# > if defined(YOKAI_USE_ARCH_INTRINSICS_AMD64)
# > if defined(YOKAI_USE_ARCH_INTRINSICS_I686)
yokai_set_arch_intrinsics("${YOKAI_TARGET_ARCH_NAME}")

set(amd64_PARENT "i686")
Expand All @@ -76,14 +156,49 @@ function(yokai_set_intrinsics)
endif()
endfunction()

yokai_detect_arch()
yokai_set_intrinsics()
yokai_detect_host_arch()
yokai_detect_target_arch()

# Makes possible to do that in CMake code:
# > if (YOKAI_TARGET_ARCH_ARM64)
set("YOKAI_TARGET_ARCH_${YOKAI_TARGET_ARCH_NAME_UPPER}" ON)
if (YOKAI_HOST_ARCH_UNKNOWN AND NOT YOKAI_TARGET_ARCH_UNKNOWN)
message(WARNING "Assuming the host architecture is the same as the target: ${YOKAI_TARGET_ARCH_NAME}")
set(YOKAI_HOST_ARCH_NAME "${YOKAI_TARGET_ARCH_NAME}")
set(YOKAI_HOST_ARCH_NAME_UPPER "${YOKAI_TARGET_ARCH_NAME_UPPER}")
set(YOKAI_HOST_ARCH_${YOKAI_HOST_ARCH_NAME_UPPER} ON)
unset(YOKAI_HOST_ARCH_UNKNOWN)
endif()

if (YOKAI_TARGET_ARCH_UNKNOWN AND NOT YOKAI_HOST_ARCH_UNKNOWN)
message(WARNING "Assuming the target architecture is the same as the host: ${YOKAI_TARGET_ARCH_NAME}")
set(YOKAI_TARGET_ARCH_NAME "${YOKAI_HOST_ARCH_NAME}")
set(YOKAI_TARGET_ARCH_NAME_UPPER "${YOKAI_HOST_ARCH_NAME_UPPER}")
set(YOKAI_TARGET_ARCH_${YOKAI_TARGET_ARCH_NAME_UPPER} ON)
unset(YOKAI_TARGET_ARCH_UNKNOWN)
endif()

if (YOKAI_HOST_ARCH_UNKNOWN)
message(WARNING "Unknown host architecture")
else()
message(STATUS "Detected host architecture: ${YOKAI_HOST_ARCH_NAME}")
endif()

if (YOKAI_TARGET_ARCH_UNKNOWN)
message(WARNING "Unknown target architecture")
else()
message(STATUS "Detected target architecture: ${YOKAI_TARGET_ARCH_NAME}")
endif()

if (NOT "${YOKAI_HOST_ARCH_NAME}" STREQUAL "${YOKAI_TARGET_ARCH_NAME}")
if ("${YOKAI_HOST_ARCH_${YOKAI_TARGET_ARCH_NAME}_PARENT}")
message(STATUS "Assuming no architecture cross-compilation")
else()
message(STATUS "Detected architecture cross-compilation")
set(YOKAI_TARGET_CROSS ON)
endif()
endif()

if (YOKAI_SOURCE_GENERATOR)
# Add printable strings to the executable.
yokai_add_buildinfo("char*" "YOKAI_ARCH_STRING" "\"${YOKAI_TARGET_ARCH_NAME}\"")
endif()

yokai_set_intrinsics()
5 changes: 5 additions & 0 deletions cmake/Yokai/Detection/Architecture.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ platform variants we cannot support anyway. */
#elif defined(Q_PROCESSOR_RISCV_64)
#pragma message(REPORT_NAME("riscv64"))

/* Devices like:
- Loongson 3A6000, 3A5000… */
#elif defined(Q_PROCESSOR_LOONGARCH_64)
#pragma message(REPORT_NAME("loong64"))

/* Remaining native NaCl architecture. */

#elif defined(Q_PROCESSOR_MIPS_32) && Q_BYTE_ORDER == Q_LITTLE_ENDIAN
Expand Down
Loading