From 995b9371dbd567d0ea77fc969bacccb7cd64dc4f Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Thu, 2 Feb 2023 14:42:28 +0100 Subject: Scripts to acquire and use UE's Linux toolchain --- scripts/ue_build_linux/README.md | 31 +++++++++++++++ scripts/ue_build_linux/clang | 2 + scripts/ue_build_linux/clang++ | 2 + scripts/ue_build_linux/get_ue_toolchain.sh | 64 ++++++++++++++++++++++++++++++ scripts/ue_build_linux/ue_build.sh | 27 +++++++++++++ 5 files changed, 126 insertions(+) create mode 100755 scripts/ue_build_linux/README.md create mode 100755 scripts/ue_build_linux/clang create mode 100755 scripts/ue_build_linux/clang++ create mode 100755 scripts/ue_build_linux/get_ue_toolchain.sh create 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 new file mode 100755 index 000000000..8cd589610 --- /dev/null +++ b/scripts/ue_build_linux/README.md @@ -0,0 +1,31 @@ +# Build Zen with the UE Linux toolchain + +This folder contains scripts to build Zen using the UE Linux toolchain. 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 + +This will download the required components from Perforce and struicture them in +such a way that they can be used by both vcpkg and xmake when building Zen. + +2) ue_build.sh [args...] + +Given the toolchain location downloaded in step (1), this script sets up a +suitable environment and execs the "prog [args...]". It is expected that this +is used to invoke xmake to build Zen; + +``` +$ scripts/ue_linux_build/ue_build.sh ~/uetools xmake config --mode=debug --vcpkg=~/vcpkg +$ scripts/ue_linux_build/ue_build.sh ~/uetools xmake build +``` + +It is possible that `--toolchain=clang` may be required as a configuration +option. The ue_build.sh script can also be source into the current shell,, +although it is worth noting that this has never been tried. + +3) clang / clang++ + +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. diff --git a/scripts/ue_build_linux/clang b/scripts/ue_build_linux/clang new file mode 100755 index 000000000..f3af44c9c --- /dev/null +++ b/scripts/ue_build_linux/clang @@ -0,0 +1,2 @@ +#!/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++ new file mode 100755 index 000000000..d2ebda549 --- /dev/null +++ b/scripts/ue_build_linux/clang++ @@ -0,0 +1,2 @@ +#!/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 new file mode 100755 index 000000000..67fd922c2 --- /dev/null +++ b/scripts/ue_build_linux/get_ue_toolchain.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +die() { echo "ERROR: $1"; exit; } + +if [ -z $1 ]; then + echo "usage: $(basename ${BASH_SOURCE[0]}) " + exit +fi + +if [ -e $1 ]; then + rmdir $1 + if [ $? -gt 0 ]; then + die "$1 is not empty" + exit + fi +fi + +mkdir -p $1 +cd $1 + +p4 login -s +if [ $? -gt 0 ]; then + die "Not logged into Perforce" +fi + +# Perforce paths +if [ -z $AUTOSDK_PATH ]; then + AUTOSDK_PATH=//depot/CarefullyRedist/HostLinux/Linux_x64/v21_clang-15.0.1-centos7/x86_64-unknown-linux-gnu +fi + +if [ -z $UE_PATH ]; then + UE_PATH=//UE5/Main +fi + +if [ -z $UE_LIBCXX_PATH ]; then + UE_LIBCXX_PATH=$UE_PATH/Engine/Source/ThirdParty/Unix/LibCxx +fi + +p4_print() { + echo -n $1 + p4 print -q -o$2/$(basename $1) $1 + echo +} + +# toolchain +p4_print $AUTOSDK_PATH/bin/clang* bin +#p4_print $AUTOSDK_PATH/bin/lld bin + +p4_print $AUTOSDK_PATH/lib/gcc/... lib/gcc +p4_print $AUTOSDK_PATH/lib/clang/*/include/... lib/clang/*/include + +# headers +p4_print $AUTOSDK_PATH/usr/include/...h usr/include + +# libraries +p4_print $AUTOSDK_PATH/lib64/* lib64 +p4_print $AUTOSDK_PATH/usr/lib64/* usr/lib64 + +mkdir -p usr/lib +mv usr/lib64/*.o usr/lib + +# ue's libc++ +p4_print $UE_LIBCXX_PATH/include/... include +p4_print $UE_LIBCXX_PATH/lib/Unix/x86_64-unknown-linux-gnu/* lib64 diff --git a/scripts/ue_build_linux/ue_build.sh b/scripts/ue_build_linux/ue_build.sh new file mode 100755 index 000000000..a15028560 --- /dev/null +++ b/scripts/ue_build_linux/ue_build.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +die() { echo ERROR: $1; exit 1; } + +# Validate input +if [ -z $1 ]; then + echo "usage: $0 " + exit 1 +fi + +if ! [ -d $1 ]; then + die "$1 is not a directory" +fi + +if [ -z $1 ]; then + die "$1/bin/clang++ does not exist" +fi + +export UE_TOOLCHAIN_DIR=$(realpath $1) +export CC="clang" +export CXX="clang++" +export LD="clang++" + +export PATH="$(realpath $(dirname ${BASH_SOURCE[0]})):$PATH" + +shift +exec $* -- cgit v1.2.3 From 1a3db6fc978a3de752fa001213927617508d3aa7 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 6 Feb 2023 14:09:36 +0100 Subject: Fixed two typos in Readme --- scripts/ue_build_linux/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts/ue_build_linux') diff --git a/scripts/ue_build_linux/README.md b/scripts/ue_build_linux/README.md index 8cd589610..1665b24a2 100755 --- a/scripts/ue_build_linux/README.md +++ b/scripts/ue_build_linux/README.md @@ -6,7 +6,7 @@ headers and libraries. There are a few components involved; 1) get_ue_toolchain.sh -This will download the required components from Perforce and struicture them in +This will download the required components from Perforce and structure them in such a way that they can be used by both vcpkg and xmake when building Zen. 2) ue_build.sh [args...] @@ -21,7 +21,7 @@ $ scripts/ue_linux_build/ue_build.sh ~/uetools xmake build ``` It is possible that `--toolchain=clang` may be required as a configuration -option. The ue_build.sh script can also be source into the current shell,, +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. 3) clang / clang++ -- cgit v1.2.3 From aa07aca9dc95ffb14b3dfaa788f22461fe0e9863 Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 6 Feb 2023 14:10:08 +0100 Subject: Added note about UE toolchain meeting VFX reference platform versions --- scripts/ue_build_linux/README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'scripts/ue_build_linux') diff --git a/scripts/ue_build_linux/README.md b/scripts/ue_build_linux/README.md index 1665b24a2..00249ddbe 100755 --- a/scripts/ue_build_linux/README.md +++ b/scripts/ue_build_linux/README.md @@ -1,8 +1,9 @@ # Build Zen with the UE Linux toolchain -This folder contains scripts to build Zen using the UE Linux toolchain. It -works by using the --sysroot= option to redirect compilers and linkers to find -headers and libraries. There are a few components involved; +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 -- cgit v1.2.3 From 9c8d24e111f5bc69bff60dfb88fe32add7579fdb Mon Sep 17 00:00:00 2001 From: Martin Ridgers Date: Mon, 6 Feb 2023 14:10:36 +0100 Subject: Fixed wrong if-statement when checking for the presence of clang++ --- scripts/ue_build_linux/ue_build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/ue_build_linux') diff --git a/scripts/ue_build_linux/ue_build.sh b/scripts/ue_build_linux/ue_build.sh index a15028560..e9c3b2cf6 100755 --- a/scripts/ue_build_linux/ue_build.sh +++ b/scripts/ue_build_linux/ue_build.sh @@ -12,7 +12,7 @@ if ! [ -d $1 ]; then die "$1 is not a directory" fi -if [ -z $1 ]; then +if ! [ -e $1/bin/clang++ ]; then die "$1/bin/clang++ does not exist" fi -- cgit v1.2.3