From 794f093057c58c4909a0653edb54fdf869560596 Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Wed, 4 Mar 2026 14:00:34 +0100 Subject: 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. --- scripts/ue_build_linux/README.md | 42 +++++++++++++++--------------- scripts/ue_build_linux/clang | 2 -- scripts/ue_build_linux/clang++ | 2 -- scripts/ue_build_linux/get_ue_toolchain.sh | 2 +- scripts/ue_build_linux/ue_build.sh | 33 ----------------------- 5 files changed, 22 insertions(+), 59 deletions(-) delete mode 100755 scripts/ue_build_linux/clang delete mode 100755 scripts/ue_build_linux/clang++ delete mode 100755 scripts/ue_build_linux/ue_build.sh (limited to 'scripts/ue_build_linux') 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 +## 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 [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=` (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]}) " 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 (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 "$@" -- cgit v1.2.3