From 63a1cccdae9c94aa1fe3894b0185aac2f2588d3c Mon Sep 17 00:00:00 2001 From: Matthew Johnson Date: Tue, 3 Dec 2024 13:25:58 -0500 Subject: [PATCH] allow build script customizations (#139) --- build.sh | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/build.sh b/build.sh index dcc5313..ee743e5 100755 --- a/build.sh +++ b/build.sh @@ -4,16 +4,21 @@ set -e # usage: ./build.sh [clean|clean --confirm|skiptest] -BUILD_DIR=cmake-build -# Choose: Debug, Release, RelWithDebInfo and MinSizeRel. Use Debug for asan checking locally. -BUILD_TYPE=Debug +if [[ -z "$BUILD_DIR" ]]; then + BUILD_DIR="cmake-build" +fi + +if [[ -z "$BUILD_TYPE" ]]; then + # Choose: Debug, Release, RelWithDebInfo and MinSizeRel. Use Debug for asan checking locally. + BUILD_TYPE="Debug" +fi BLUE="\033[0;34m" NC="\033[0m" if [[ "$1" == "clean" ]]; then echo -e "${BLUE}==== clean ====${NC}" - rm -rf $BUILD_DIR + rm -rf "$BUILD_DIR" rm -rf lib/spectator if [[ "$2" == "--confirm" ]]; then # remove all packages from the conan cache, to allow swapping between Release/Debug builds @@ -34,16 +39,16 @@ fi if [[ ! -d $BUILD_DIR ]]; then echo -e "${BLUE}==== install required dependencies ====${NC}" if [[ "$BUILD_TYPE" == "Debug" ]]; then - conan install . --output-folder=$BUILD_DIR --build="*" --settings=build_type=$BUILD_TYPE --profile=./sanitized + conan install . --output-folder="$BUILD_DIR" --build="*" --settings=build_type="$BUILD_TYPE" --profile=./sanitized else - conan install . --output-folder=$BUILD_DIR --build=missing + conan install . --output-folder="$BUILD_DIR" --build=missing fi echo -e "${BLUE}==== install source dependencies ====${NC}" conan source . fi -pushd $BUILD_DIR +pushd "$BUILD_DIR" echo -e "${BLUE}==== configure conan environment to access tools ====${NC}" source conanbuild.sh @@ -56,7 +61,7 @@ echo -e "${BLUE}==== generate build files ====${NC}" if [[ "$TITUS_SYSTEM_SERVICE" != "ON" ]]; then TITUS_SYSTEM_SERVICE=OFF fi -cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DTITUS_SYSTEM_SERVICE="$TITUS_SYSTEM_SERVICE" +cmake .. -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE="$BUILD_TYPE" -DTITUS_SYSTEM_SERVICE="$TITUS_SYSTEM_SERVICE" echo -e "${BLUE}==== build ====${NC}" cmake --build .