From 55ce47676bf0b1e8870adbda6fef3ae294b17fb3 Mon Sep 17 00:00:00 2001 From: Nicky Date: Mon, 17 Jan 2022 18:24:06 +0100 Subject: [PATCH] Add option to enable compiler cache (if found). --- scripts/configure_firestorm.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/scripts/configure_firestorm.sh b/scripts/configure_firestorm.sh index 1b09dfbbfa..e6615fbb3d 100755 --- a/scripts/configure_firestorm.sh +++ b/scripts/configure_firestorm.sh @@ -42,6 +42,7 @@ WANTS_TESTBUILD=$FALSE WANTS_TRACY=$FALSE WANTS_BUILD=$FALSE WANTS_CRASHREPORTING=$FALSE +WANTS_CACHE=$FALSE TARGET_PLATFORM="darwin" # darwin, windows, linux BTYPE="Release" CHANNEL="" # will be overwritten later with platform-specific values unless manually specified. @@ -85,6 +86,7 @@ showUsage() echo " --jobs : Build with jobs in parallel (Linux and Darwin only)" echo " --ninja : Build using Ninja" echo " --vscode : Exports compile commands for VSCode (Linux only)" + echo " --compiler-cache : Try to detect and use compiler cache (needs also --ninja for OSX and Windows)" echo echo "All arguments not in the above list will be passed through to LL's configure/build." echo @@ -94,7 +96,7 @@ getArgs() # $* = the options passed in from main { if [ $# -gt 0 ]; then - while getoptex "clean build config version package no-package fmodstudio openal ninja vscode jobs: platform: kdu opensim no-opensim singlegrid: avx avx2 tracy crashreporting testbuild: help chan: btype:" "$@" ; do + while getoptex "clean build config version package no-package fmodstudio openal ninja vscode compiler-cache jobs: platform: kdu opensim no-opensim singlegrid: avx avx2 tracy crashreporting testbuild: help chan: btype:" "$@" ; do #ensure options are valid if [ -z "$OPTOPT" ] ; then @@ -133,6 +135,7 @@ getArgs() jobs) JOBS="$OPTARG";; ninja) WANTS_NINJA=$TRUE;; vscode) WANTS_VSCODE=$TRUE;; + compiler-cache) WANTS_CACHE=$TRUE;; help) showUsage && exit 0;; @@ -324,6 +327,7 @@ echo -e " BUILD: `b2a $WANTS_BUILD`" | echo -e " CONFIG: `b2a $WANTS_CONFIG`" | tee -a $LOG echo -e " NINJA: `b2a $WANTS_NINJA`" | tee -a $LOG echo -e " VSCODE: `b2a $WANTS_VSCODE`" | tee -a $LOG +echo -e " COMPILER CACHE: `b2a $WANTS_CACHE`" | tee -a $LOG echo -e " PASSTHRU: $LL_ARGS_PASSTHRU" | tee -a $LOG echo -e " BTYPE: $BTYPE" | tee -a $LOG if [ $TARGET_PLATFORM == "linux" -o $TARGET_PLATFORM == "darwin" ] ; then @@ -545,8 +549,24 @@ if [ $WANTS_CONFIG -eq $TRUE ] ; then TARGET="Ninja" fi + CACHE_OPT="" + + if [ $WANTS_CACHE -eq $TRUE ] + then + if [ `which ccache 2>/dev/null` ] + then + echo "Found ccache" + CACHE_OPT="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" + fi + if [ `which buildcache 2>/dev/null` ] + then + echo "Found buildcache" + CACHE_OPT="-DCMAKE_C_COMPILER_LAUNCHER=buildcache -DCMAKE_CXX_COMPILER_LAUNCHER=buildcache" + fi + fi + cmake -G "$TARGET" ../indra $CHANNEL ${GITHASH} $FMODSTUDIO $OPENAL $KDU $OPENSIM $SINGLEGRID $AVX_OPTIMIZATION $AVX2_OPTIMIZATION $TRACY_PROFILER $TESTBUILD $PACKAGE \ - $UNATTENDED -DLL_TESTS:BOOL=OFF -DADDRESS_SIZE:STRING=$AUTOBUILD_ADDRSIZE -DCMAKE_BUILD_TYPE:STRING=$BTYPE \ + $UNATTENDED -DLL_TESTS:BOOL=OFF -DADDRESS_SIZE:STRING=$AUTOBUILD_ADDRSIZE -DCMAKE_BUILD_TYPE:STRING=$BTYPE $CACHE_OPT \ $CRASH_REPORTING -DVIEWER_SYMBOL_FILE:STRING="${VIEWER_SYMBOL_FILE:-}" -DROOT_PROJECT_NAME:STRING=Firestorm $LL_ARGS_PASSTHRU ${VSCODE_FLAGS:-} | tee $LOG if [ $TARGET_PLATFORM == "windows" ] ; then