aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2026-03-04 14:00:34 +0100
committerGitHub Enterprise <[email protected]>2026-03-04 14:00:34 +0100
commit794f093057c58c4909a0653edb54fdf869560596 (patch)
treea730072e40f7eb60c7761ffb44c939aa1ad981bb /scripts
parentIterateChunks callback is multithreaded - make sure AttachmentsSize can handl... (diff)
downloadzen-794f093057c58c4909a0653edb54fdf869560596.tar.xz
zen-794f093057c58c4909a0653edb54fdf869560596.zip
native xmake toolchain definition for UE-clang (#805)
This change is meant to provide a smoother experience when working on Linux. After this change, the toolchain setup process is now simply ```bash $ scripts/ue_build_linux/get_ue_toolchain.sh ``` and then at config time the toolchain is automatically detected if you downloaded it to the default location or have the `UE_TOOLCHAIN_DIR` environment variable set ```bash xmake config --mode=debug ``` Compared to the old script-based approach this configures the toolchain more precisely, avoiding leakage into unrelated build processes such as when a package manager decides to build something like Ninja locally etc.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/bundle.lua10
-rwxr-xr-xscripts/ue_build_linux/README.md42
-rwxr-xr-xscripts/ue_build_linux/clang2
-rwxr-xr-xscripts/ue_build_linux/clang++2
-rwxr-xr-xscripts/ue_build_linux/get_ue_toolchain.sh2
-rwxr-xr-xscripts/ue_build_linux/ue_build.sh33
6 files changed, 32 insertions, 59 deletions
diff --git a/scripts/bundle.lua b/scripts/bundle.lua
index 07e120d04..b2a5e1e08 100644
--- a/scripts/bundle.lua
+++ b/scripts/bundle.lua
@@ -17,7 +17,15 @@ end
--------------------------------------------------------------------------------
local function _build(arch, debug, config_args)
+ import("core.project.config")
+ config.load()
+
variant = debug and "debug" or "release"
+
+ -- Preserve toolchain/sdk from current config so --clean doesn't lose them
+ local toolchain_arg = config.get("toolchain") and ("--toolchain=" .. config.get("toolchain")) or nil
+ local sdk_arg = config.get("sdk") and ("--sdk=" .. config.get("sdk")) or nil
+
local ret = _exec(
"xmake",
"config",
@@ -26,6 +34,8 @@ local function _build(arch, debug, config_args)
"--mode="..variant,
"--arch="..arch,
"--zensentry=yes",
+ toolchain_arg,
+ sdk_arg,
config_args)
if ret > 0 then
raise("Failed to configure xmake")
diff --git a/scripts/ue_build_linux/README.md b/scripts/ue_build_linux/README.md
index e93a234ae..afafcbe24 100755
--- a/scripts/ue_build_linux/README.md
+++ b/scripts/ue_build_linux/README.md
@@ -2,38 +2,38 @@
This folder contains scripts to build Zen using the UE Linux toolchain. This
can be used to output binaries that meet the VFX Reference Platform versions.
-It works by using the `--sysroot=` option to redirect compilers and linkers to
-find headers and libraries. There are a few components involved;
-1) get_ue_toolchain.sh <toolchain_dir>
+## Setup
+
+Download the toolchain using `get_ue_toolchain.sh`:
```
-$ scripts/ue_build_linux/get_ue_toolchain.sh ./.tmp-ue-toolchain
+$ scripts/ue_build_linux/get_ue_toolchain.sh
```
-This will download the required components from cdn.unrealengine.com and
-structure them in such a way that they can be used by both vcpkg and xmake
-when building Zen.
+By default this downloads to `~/.ue-toolchain`. A custom path can be given as
+the first argument, or via the `UE_TOOLCHAIN_DIR` environment variable.
-2) ue_build.sh <toolchain_dir> <prog> [args...]
+This will download the required components from cdn.unrealengine.com and
+structure them in such a way that they can be used by xmake when building Zen.
-Given the toolchain location downloaded in step (1) and the `VCPKG_ROOT`
-environment variable is properly configured, this script sets up a suitable
-environment and execs the "prog [args...]".
+## Building
-It is expected that this is used to invoke xmake to build Zen;
+xmake automatically detects the toolchain at `~/.ue-toolchain`, so no extra
+flags are needed:
```
-$ scripts/ue_build_linux/ue_build.sh .tmp-ue-toolchain xmake config --mode=debug
-$ scripts/ue_build_linux/ue_build.sh .tmp-ue-toolchain xmake build
+$ xmake config -y -m debug
+$ xmake build -y
```
-It is possible that `--toolchain=clang` may be required as a configuration
-option. The `ue_build.sh` script can also be sourced into the current shell,
-although it is worth noting that this has never been tried.
+To build a release bundle:
-3) `scripts/ue_build_linux/clang` / `scripts/ue_build_linux/clang++`
+```
+$ xmake config -y -m release
+$ xmake bundle -y
+```
-These acts as shims to the binaries in `toolchain_dir`, adding in the required
-command line arguments to use the correct headers and libraries.
-The `ue_build.sh` script adjusts `$PATH` appropriately.
+The toolchain can also be selected explicitly with `--toolchain=ue-clang`, and
+the SDK location can be overridden with `--sdk=<path>` (must be absolute) or
+the `UE_TOOLCHAIN_DIR` environment variable.
diff --git a/scripts/ue_build_linux/clang b/scripts/ue_build_linux/clang
deleted file mode 100755
index 9666ba4ba..000000000
--- a/scripts/ue_build_linux/clang
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-exec $UE_TOOLCHAIN_DIR/bin/clang --sysroot=$UE_TOOLCHAIN_DIR $CFLAGS "$@"
diff --git a/scripts/ue_build_linux/clang++ b/scripts/ue_build_linux/clang++
deleted file mode 100755
index be106ae87..000000000
--- a/scripts/ue_build_linux/clang++
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-exec $UE_TOOLCHAIN_DIR/bin/clang++ --sysroot=$UE_TOOLCHAIN_DIR -stdlib=libc++ $CXXFLAGS "$@"
diff --git a/scripts/ue_build_linux/get_ue_toolchain.sh b/scripts/ue_build_linux/get_ue_toolchain.sh
index c2538b09a..0afd40fe3 100755
--- a/scripts/ue_build_linux/get_ue_toolchain.sh
+++ b/scripts/ue_build_linux/get_ue_toolchain.sh
@@ -5,7 +5,7 @@ ZEN_ROOT=$(realpath $SCRIPT_DIR/../..)
die() { echo "ERROR: $1"; exit; }
-toolchain_dir="${1:-${ZEN_ROOT}/.tmp-ue-toolchain}"
+toolchain_dir="${1:-${UE_TOOLCHAIN_DIR:-${HOME}/.ue-toolchain}}"
if [[ $toolchain_dir == "--help" ]]; then
echo "usage: $(basename ${BASH_SOURCE[0]}) <output_dir>"
diff --git a/scripts/ue_build_linux/ue_build.sh b/scripts/ue_build_linux/ue_build.sh
deleted file mode 100755
index 690f9f661..000000000
--- a/scripts/ue_build_linux/ue_build.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash
-
-SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
-ZEN_ROOT=$(realpath $SCRIPT_DIR/../..)
-
-die() { echo ERROR: $1; exit 1; }
-
-if [[ $1 == "--help" ]]; then
- echo "usage: $0 <ue_toolchain_dir> (defaults to ${ZEN_ROOT}/.tmp-ue-toolchain)"
- exit
-fi
-
-toolchain_dir="${1:-${ZEN_ROOT}/.tmp-ue-toolchain}"
-
-# Validate input
-
-if ! [ -d $toolchain_dir ]; then
- die "$1 is not a directory"
-fi
-
-if ! [ -e $toolchain_dir/bin/clang++ ]; then
- die "$1/bin/clang++ does not exist"
-fi
-
-export UE_TOOLCHAIN_DIR=$(realpath $toolchain_dir)
-export CC="clang"
-export CXX="clang++"
-export LD="clang++"
-
-export PATH="$(realpath $(dirname ${BASH_SOURCE[0]})):$PATH"
-
-shift
-exec "$@"