aboutsummaryrefslogtreecommitdiff
path: root/xmake.lua
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2025-11-07 14:49:13 +0100
committerGitHub Enterprise <[email protected]>2025-11-07 14:49:13 +0100
commit24e43a913f29ac3b314354e8ce5175f135bcc64f (patch)
treeca442937ceeb63461012b33a4576e9835099f106 /xmake.lua
parentget oplog attachments (#622) (diff)
downloadzen-24e43a913f29ac3b314354e8ce5175f135bcc64f.tar.xz
zen-24e43a913f29ac3b314354e8ce5175f135bcc64f.zip
switch to xmake for package management (#611)
This change removes our dependency on vcpkg for package management, in favour of bringing some code in-tree in the `thirdparty` folder as well as using the xmake build-in package management feature. For the latter, all the package definitions are maintained in the zen repo itself, in the `repo` folder. It should now also be easier to build the project as it will no longer depend on having the right version of vcpkg installed, which has been a common problem for new people coming in to the codebase. Now you should only need xmake to build. * Bumps xmake requirement on github runners to 2.9.9 to resolve an issue where xmake on Windows invokes cmake with `v144` toolchain which does not exist * BLAKE3 is now in-tree at `thirdparty/blake3` * cpr is now in-tree at `thirdparty/cpr` * cxxopts is now in-tree at `thirdparty/cxxopts` * fmt is now in-tree at `thirdparty/fmt` * robin-map is now in-tree at `thirdparty/robin-map` * ryml is now in-tree at `thirdparty/ryml` * sol2 is now in-tree at `thirdparty/sol2` * spdlog is now in-tree at `thirdparty/spdlog` * utfcpp is now in-tree at `thirdparty/utfcpp` * xmake package repo definitions is in `repo` * implemented support for sanitizers. ASAN is supported on windows, TSAN, UBSAN, MSAN etc are supported on Linux/MacOS though I have not yet tested it extensively on MacOS * the zencore encryption implementation also now supports using mbedTLS which is used on MacOS, though for now we still use openssl on Linux * crashpad * bumps libcurl to 8.11.0 (from 8.8.0) which should address a rare build upload bug
Diffstat (limited to 'xmake.lua')
-rw-r--r--xmake.lua127
1 files changed, 96 insertions, 31 deletions
diff --git a/xmake.lua b/xmake.lua
index b5f0a26b5..4c19a1b03 100644
--- a/xmake.lua
+++ b/xmake.lua
@@ -2,44 +2,104 @@
set_configvar("ZEN_SCHEMA_VERSION", 5) -- force state wipe after 0.2.31 causing bad data (dan.engelbrecht)
-add_requires(
- "vcpkg::blake3",
- "vcpkg::curl",
- "vcpkg::cxxopts",
- "vcpkg::doctest",
- "vcpkg::eastl",
- "vcpkg::fmt",
- "vcpkg::gsl-lite",
- "vcpkg::http-parser",
- "vcpkg::json11",
- "vcpkg::lua",
- "vcpkg::lz4",
- "vcpkg::ryml",
- "vcpkg::c4core",
- "vcpkg::robin-map",
- "vcpkg::sol2",
- "vcpkg::xxhash",
- "vcpkg::zlib"
-)
+--------------------------------------------------------------------------
+-- We support debug and release modes. On Windows we use static CRT to
+-- minimize dependencies.
-add_defines("EASTL_STD_ITERATOR_CATEGORY_ENABLED", "EASTL_DEPRECATIONS_FOR_2024_APRIL=EA_DISABLED")
+add_rules("mode.debug", "mode.release")
+
+if is_plat("windows") then
+ if false then
+ -- DLL runtime
+ if is_mode("debug") then
+ set_runtimes("MDd")
+ else
+ set_runtimes("MD")
+ end
+ else
+ -- static runtime
+ if is_mode("debug") then
+ set_runtimes("MTd")
+ else
+ set_runtimes("MT")
+ end
+ end
+end
+
+--------------------------------------------------------------------------
+-- Sanitizers
+--
+-- https://xmake.io/api/description/builtin-policies.html#build-sanitizer-address
+--
+-- When using sanitizers, it may be necessary to change some configuration
+-- options. In particular, you may want to use `--zensentry=no` to disable
+-- Sentry support as it may not be compatible with some sanitizers. Also,
+-- it may be necessary to disable mimalloc by using `--zenmimalloc=no`.
+
+-- AddressSanitizer is supported on Windows (MSVC 2019+), Linux, and MacOS
+
+local use_asan = false -- Automatically disables Sentry when set to true
+set_policy("build.sanitizer.address", use_asan)
+-- ThreadSanitizer, MemorySanitizer, LeakSanitizer, and UndefinedBehaviorSanitizer
+-- are supported on Linux and MacOS only.
+
+--set_policy("build.sanitizer.thread", true)
+--set_policy("build.sanitizer.memory", true)
+--set_policy("build.sanitizer.leak", true)
+--set_policy("build.sanitizer.undefined", true)
+
+--------------------------------------------------------------------------
+-- Dependencies
+
+add_repositories("zen-repo repo")
set_policy("build.ccache", false)
+set_policy("package.precompiled", false)
+
+add_defines("gsl_FEATURE_GSL_COMPATIBILITY_MODE=1")
+add_requires("gsl-lite", {system = false})
+add_requires("http_parser", {system = false})
+add_requires("json11", {system = false})
+add_requires("lua", {system = false})
+add_requires("lz4", {system = false})
+add_requires("mimalloc", {system = false})
+add_requires("xxhash", {system = false})
+add_requires("zlib", {system = false})
+
+add_defines("EASTL_STD_ITERATOR_CATEGORY_ENABLED", "EASTL_DEPRECATIONS_FOR_2024_APRIL=EA_DISABLED")
+add_requires("eastl", {system = false})
+
+--------------------------------------------------------------------------
+-- Crypto configuration. For reasons unknown each platform needs a
+-- different package
if is_plat("windows") then
+ -- we use schannel on Windows
add_defines("ZEN_USE_OPENSSL=0")
-else
- add_requires("vcpkg::openssl")
+ add_requires("libcurl", {system = false})
+elseif is_plat("linux") then
+ add_requires("openssl3", {system = false})
+ add_defines("ZEN_USE_OPENSSL=1")
+ add_requires("libcurl", {system = false, configs = {openssl3 = true}})
+elseif is_plat("macosx") then
+ add_requires("mbedtls", {system = false})
+ add_defines("ZEN_USE_OPENSSL=0")
+ add_defines("ZEN_USE_MBEDTLS=1")
+ add_requires("libcurl", {system = false, configs = {mbedtls = true}})
end
+--------------------------------------------------------------------------
+
if is_plat("windows") then
- -- for bundling, linux tries to compile from source which fails with UE toolchain, fallback is regular zip
+ -- for bundling, Linux tries to compile from source which fails with UE toolchain,
+ -- fallback is regular zip
add_requires("7z")
end
-- If we're using the UE cross-compile toolchain, we need to ensure we link statically
-- against the toolchain libc++ and libc++abi, as the system ones can differ in ABI
-- leading to nasty crashes
+
if is_plat("linux") and os.getenv("UE_TOOLCHAIN_DIR") then
add_ldflags("-static-libstdc++")
add_ldflags("$(projectdir)/thirdparty/ue-libcxx/lib64/libc++.a")
@@ -47,22 +107,24 @@ if is_plat("linux") and os.getenv("UE_TOOLCHAIN_DIR") then
set_toolset("objcopy", "$(env UE_TOOLCHAIN_DIR)/bin/llvm-objcopy")
end
-add_requires("vcpkg::mimalloc")
-
-if has_config("zensentry") then
+if has_config("zensentry") and not use_asan then
if is_plat("linux") then
- add_requires("vcpkg::sentry-native 0.5.4")
+ add_requires("sentry-native 0.7.6")
+ elseif is_plat("windows") then
+ add_requires("sentry-native 0.7.6", {debug = is_mode("debug"), configs = {backend = "crashpad"}})
else
- add_requires("vcpkg::sentry-native")
+ add_requires("sentry-native 0.7.6", {configs = {backend = "crashpad"}})
end
end
-add_rules("mode.debug", "mode.release")
--add_rules("c++.unity_build")
if is_mode("release") then
- -- LTO does not appear to work with the current UE toolchain
- if not is_plat("linux") then
+ -- LTO does not appear to work with the current Linux UE toolchain
+ -- It's currently also temporarily disabled on Windows to investigate
+ -- build issues due to git apply not applying the necessary patches correctly
+ -- in CI for some reason.
+ if not is_plat("linux", "windows") then
set_policy("build.optimization.lto", true)
end
set_optimize("fastest")
@@ -103,6 +165,7 @@ if is_os("windows") then
add_ldflags("/PDBALTPATH:%_PDB%") -- deterministic pdb reference in exe
add_cxxflags("/Zc:preprocessor") -- Enable preprocessor conformance mode
+ add_cxxflags("/Zc:u8EscapeEncoding") -- Enable UTF-8 encoding for u8 string literals
-- add_ldflags("/MAP")
end
@@ -212,6 +275,8 @@ includes("src/zenserver", "src/zenserver-test")
includes("src/zen")
includes("src/zentest-appstub")
+--------------------------------------------------------------------------
+
task("bundle")
set_menu {
usage = "xmake bundle",