Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
e2bc65d
external_deps: add smart_copy
illwieckz Jun 25, 2026
592bd97
external_deps: do not copy WASI into WASI
illwieckz Jun 25, 2026
6043bf4
external_deps: better wasmtime copy
illwieckz Jun 25, 2026
a42459b
external_deps: better sdl3 copy
illwieckz Jun 25, 2026
4a4b040
external_deps: better copy in extract()
illwieckz Jun 25, 2026
3faf1b5
external_deps: build naclruntime with cmake
illwieckz Jun 25, 2026
c2644ff
external_deps: make possible to reconfigure for a different target
illwieckz Jun 25, 2026
fb8fe39
external_deps: make defaults resetable with setup_default()
illwieckz Jun 25, 2026
ed46d33
cmake,external_deps,ld: expect loader be packaged with architecture s…
illwieckz Jun 26, 2026
f16369a
external_deps: repackage saigosdk
illwieckz Jun 25, 2026
c92c9dd
cmake: use Saigo by default to compile NaCl binaries
illwieckz Jun 26, 2026
ce281aa
external_deps: build pkg-config as a native tool
illwieckz Jun 26, 2026
5cc947b
external_deps: build nasm as a native tool
illwieckz Jun 26, 2026
9586e5b
external_deps: build jwasm as a native tool
illwieckz Jun 26, 2026
70eb1b1
cmake,virtualmachine,ld: append the architecture name to loader binar…
illwieckz Jun 26, 2026
4b0db89
external_deps: upgrade sdl3
illwieckz Jun 26, 2026
c602875
external_deps: upgrade zlib
illwieckz Jun 26, 2026
847a5bf
external_deps: upgrade nettle
illwieckz Jun 26, 2026
9c0e8a5
external_deps: upgrade curl
illwieckz Jun 26, 2026
e07784c
external_deps: upgrade glew
illwieckz Jun 26, 2026
432dafa
external_deps: upgrade png
illwieckz Jun 26, 2026
fd43f8c
external_deps: upgrade jpeg
illwieckz Jun 26, 2026
a797a60
external_deps: do not upgrade openal
illwieckz Jun 26, 2026
2e67140
external_deps: upgrade opus
illwieckz Jun 26, 2026
cbb05b4
external_deps: disable the GPU framework
illwieckz Jun 26, 2026
ed0fc77
external_deps: make possible to loop the cmake build
illwieckz Jun 27, 2026
af3f5c1
external_deps: extract platform components
illwieckz Jun 25, 2026
5c0c84f
external_deps: add macos-arm64-default
illwieckz Jun 26, 2026
5c8c097
external_deps: rework the cmake toolchain configuration
illwieckz Jun 27, 2026
eb0024b
external_deps: rework the macos configuration
illwieckz Jun 27, 2026
c644e16
external_deps: deduplicate files with hardlinks before making the tar…
illwieckz Jun 27, 2026
a8d618b
external_deps: tell xz to use extreme compression
illwieckz Jun 27, 2026
80d36b0
external_deps: make EXE_EXT reusable
illwieckz Jun 25, 2026
7b50e6d
cmake: download macos-arm64 deps archive
illwieckz Jun 27, 2026
d5293b5
external_deps: deduplicate nacl from pnacl copy code
illwieckz Jun 27, 2026
dbb71f5
external_deps: provide a reusable framework for building native tools…
illwieckz Jun 26, 2026
d6ef012
ci/azure: macos-arm64
illwieckz Jun 27, 2026
49595ab
yokai: update qprocessordetection.h from Qt upstream and recognize lo…
illwieckz Jun 29, 2026
237adac
yokai: rework of the architecture and system detection
illwieckz Jun 29, 2026
4b20733
yokai: detect host architecture
illwieckz Jun 29, 2026
2cca4d5
cmake: use box64 on loong64
illwieckz Jun 29, 2026
910700e
external_deps: box64
illwieckz Jul 3, 2026
41cd9db
external_deps: amd64 nacl_loader on arm64
illwieckz Jul 3, 2026
7cc3851
cmake: rework the code enabling nexe build when there is an nacl sdk,…
illwieckz Jul 3, 2026
12a6eba
cmake: multiarch nexe
illwieckz Jul 3, 2026
5cff58b
cmake: copy box64
illwieckz Jul 3, 2026
84ddaea
external_deps: box64 install for arm64
illwieckz Jul 3, 2026
f56d45c
cmake: enable box64 on arm64
illwieckz Jul 3, 2026
5f85931
virtualmachine: detect armhf multiarch support
illwieckz Jul 3, 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
95 changes: 45 additions & 50 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ if (Daemon_OUT)
endif()

include(Yokai/All)
include(DaemonNaclHost)

include(DaemonNaclArchitecture)

daemon_detect_nacl_arch("${YOKAI_TARGET_ARCH_NAME}")

# Add printable strings to the executable.
yokai_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH_NAME}\"")

################################################################################
# Configuration options
Expand Down Expand Up @@ -190,7 +196,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 +226,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 @@ -970,56 +966,55 @@ if (DEPS_DIR AND HAS_NACL AND (BUILD_CLIENT OR BUILD_TTY_CLIENT OR BUILD_SERVER
add_custom_target(runtime_deps)
set_target_properties(runtime_deps PROPERTIES FOLDER "CMakePlumbing")

# 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}
)
foreach(arch_name IN LISTS DAEMON_NACL_ARCH_NAME_LIST)
# 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-${arch_name}${CMAKE_EXECUTABLE_SUFFIX}
${FULL_OUTPUT_DIR}/nacl_loader-${arch_name}${CMAKE_EXECUTABLE_SUFFIX}
)

add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${DEPS_DIR}/irt_core-${DAEMON_NACL_ARCH_NAME}.nexe
${FULL_OUTPUT_DIR}/irt_core-${DAEMON_NACL_ARCH_NAME}.nexe
)
add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${DEPS_DIR}/irt_core-${arch_name}.nexe
${FULL_OUTPUT_DIR}/irt_core-${arch_name}.nexe
)
endforeach()

# 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
${FULL_OUTPUT_DIR}/lib-armhf
COMMAND ${CMAKE_COMMAND} -E copy_directory
${DEPS_DIR}/libs-linux-armhf
${FULL_OUTPUT_DIR}/libs-linux-armhf
)
endif()

foreach(arch_name IN LISTS DAEMON_NACL_ARCH_NAME_LIST)
add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${DEPS_DIR}/lib-armhf
${FULL_OUTPUT_DIR}/lib-armhf
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${DEPS_DIR}/nacl_helper_bootstrap-${arch_name}
${FULL_OUTPUT_DIR}/nacl_helper_bootstrap-${arch_name}
)
endif()
endforeach()

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
)
endif()
if (DAEMON_NACL_BOX64_EMULATION)
add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${DEPS_DIR}/box64
${FULL_OUTPUT_DIR}/box64
)

# Win32 requires nacl_loader_amd64.exe in order to run on Win64
if (YOKAI_TARGET_SYSTEM_WINDOWS AND YOKAI_TARGET_ARCH_I686)
add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${DEPS_DIR}/nacl_loader-amd64${CMAKE_EXECUTABLE_SUFFIX}
${FULL_OUTPUT_DIR}/nacl_loader-amd64${CMAKE_EXECUTABLE_SUFFIX}
)
add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${DEPS_DIR}/irt_core-amd64.nexe
${FULL_OUTPUT_DIR}/irt_core-amd64.nexe
)
add_custom_command(TARGET runtime_deps PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${DEPS_DIR}/libs-linux-amd64
${FULL_OUTPUT_DIR}/libs-linux-amd64
)
endif()
endif()

# Mac requires some libraries from external_deps
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
27 changes: 21 additions & 6 deletions cmake/DaemonGame.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,18 @@ set(SHAREDLIST_sgame
# Function to setup all the Sgame/Cgame libraries
include(CMakeParseArguments)

# The NaCl SDK only runs on amd64 or i686.
if (USE_NACL_SAIGO)
set(HAS_NACL_SDK ON)
elseif (CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME
AND (YOKAI_TARGET_ARCH_AMD64 OR YOKAI_TARGET_ARCH_I686))
# The PNaCl SDK only runs on amd64 or i686.
set(HAS_NACL_SDK ON)
endif()

if (NOT FORK EQUAL 2)
if (CMAKE_SYSTEM_NAME STREQUAL CMAKE_HOST_SYSTEM_NAME
AND (YOKAI_TARGET_ARCH_AMD64 OR YOKAI_TARGET_ARCH_I686))
if (HAS_NACL_SDK)
include(DaemonNaclArchitecture)

# can be loaded by daemon with vm.[sc]game.type 0 or 1
option(BUILD_GAME_NACL "Build the NaCl \"pexe\" and \"nexe\" gamelogic modules for enabled architecture targets, required to host mods." OFF)

Expand All @@ -89,10 +97,17 @@ if (NOT FORK EQUAL 2)
set(NACL_TARGETS "${BUILD_GAME_NACL_TARGETS}")
endif()

foreach(NACL_TARGET ${NACL_TARGETS})
foreach(NACL_TARGET IN LISTS NACL_TARGETS)
daemon_detect_nacl_arch("${NACL_TARGET}")

set(NACL_TARGETS "${DAEMON_NACL_ARCH_NAME_LIST}")
endforeach()

foreach(NACL_TARGET IN LISTS NACL_TARGETS)
set(IS_NACL_VALID_TARGET OFF)
foreach(NACL_VALID_TARGET ${NACL_ALL_TARGETS})
if(NACL_TARGET STREQUAL NACL_VALID_TARGET)

foreach(NACL_VALID_TARGET IN LISTS NACL_ALL_TARGETS)
if (NACL_TARGET STREQUAL NACL_VALID_TARGET)
set(IS_NACL_VALID_TARGET ON)
endif()
endforeach()
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
63 changes: 37 additions & 26 deletions cmake/DaemonNaclHost.cmake → cmake/DaemonNaclArchitecture.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,41 +24,61 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

function(daemon_detect_nacl_arch)
set(target_arch "${YOKAI_TARGET_ARCH_NAME}")
set(nacl_arch "${target_arch}")
function(daemon_detect_nacl_arch target_arch)
macro(add_nacl_arch arch_name)
list(APPEND nacl_arch_list "${arch_name}")
message(STATUS "Available NaCl architecture: ${arch_name}")
endmacro()

# NaCl runtime is only available on architectures that have a NaCl loader.
set(nacl_runtime_arch "amd64" "i686" "armhf")

if (YOKAI_TARGET_SYSTEM_WINDOWS)
if("${target_arch}" STREQUAL "amd64")
add_nacl_arch("${target_arch}")
elseif("${target_arch}" STREQUAL "i686")
# Win32 requires nacl_loader-amd64.exe in order to run on Win64
add_nacl_arch("${target_arch}")
add_nacl_arch("amd64")
endif()
elseif (YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY OR YOKAI_TARGET_SYSTEM_XDG_COMPATIBILITY)
if ("${target_arch}" IN_LIST nacl_runtime_arch)
add_nacl_arch("${target_arch}")
endif()

if (YOKAI_TARGET_SYSTEM_LINUX_COMPATIBILITY OR YOKAI_TARGET_SYSTEM_XDG_COMPATIBILITY)
set(armhf_usage "arm64" "armel")
set(box64_usage "ppc64el" "riscv64")
set(box64_usage "arm64" "ppc64el" "riscv64" "loong64")

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)
add_nacl_arch("armhf")
endif()

if ("${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.
# Box64 must be installed and available in PATH at runtime.
set(nacl_arch "amd64")
add_nacl_arch("amd64")
add_definitions(-DDAEMON_NACL_BOX64_EMULATION)
endif()
endif()
elseif (YOKAI_TARGET_SYSTEM_MACOS)
if ("${target_arch}" STREQUAL "arm64")
if ("${target_arch}" STREQUAL "amd64")
add_nacl_arch("${target_arch}")
elseif ("${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")
add_nacl_arch("amd64")
endif()
endif()

string(TOUPPER "${nacl_arch}" nacl_arch_upper)
if (nacl_arch_list)
list(GET nacl_arch_list 0 nacl_arch)

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

add_definitions(-DDAEMON_NACL_RUNTIME_ENABLED)
else()
Expand All @@ -69,15 +89,6 @@ function(daemon_detect_nacl_arch)

# 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)
# Those names are used to copy the loader and the IRT binaries.
set(DAEMON_NACL_ARCH_NAME_LIST "${nacl_arch_list}" PARENT_SCOPE)
endfunction()

daemon_detect_nacl_arch()

# Makes possible to do that in CMake code:
# > if (DAEMON_NACL_ARCH_ARMHF)
set("DAEMON_NACL_ARCH_${DAEMON_NACL_ARCH_NAME_UPPER}" ON)

# Add printable strings to the executable.
yokai_add_buildinfo("char*" "DAEMON_NACL_ARCH_STRING" "\"${DAEMON_NACL_ARCH_NAME}\"")
Loading
Loading