From 164b778fcbf6d0e84336bedee6278d8a119cddce Mon Sep 17 00:00:00 2001 From: Daniel Juenger <2955913+sleeepyjack@users.noreply.github.com> Date: Fri, 17 Nov 2023 01:43:07 +0000 Subject: [PATCH] Add options to perform a clean build and debug build --- ci/build.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 0d909c433..d6d449fcf 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -22,7 +22,8 @@ cd "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"; # Script defaults BUILD_PREFIX=../build # /build BUILD_INFIX=local # /build/local -BUILD_TYPE=Release # CMake build type +DEBUG_BUILD=0 # Default build type is Release +CLEAN_BUILD=0 # Re-use existing artifacts by-default HOST_COMPILER=${CXX:-g++} # $CXX if set, otherwise `g++` CUDA_COMPILER=${CUDACXX:-nvcc} # $CUDACXX if set, otherwise `nvcc` CXX_STANDARD=17 @@ -38,7 +39,8 @@ function usage { echo " -v/--verbose: enable shell echo for debugging" echo " -prefix: Build directory prefix (Defaults to /build)" echo " -i/-infix: Build directory infix (Defaults to local)" - echo " -t/-type: CMake build type (Defaults to Release)" + echo " -d/-debug: Debug build" + echo " -c/-clean: Clean (re-)build" echo " -cuda: CUDA compiler (Defaults to \$CUDACXX if set, otherwise nvcc)" echo " -cxx: Host compiler (Defaults to \$CXX if set, otherwise g++)" echo " -arch: Target CUDA arches, e.g. \"60-real;70;80-virtual\" (Defaults to the system's native GPU archs)" @@ -63,7 +65,8 @@ while [ "${#args[@]}" -ne 0 ]; do -v | --verbose) VERBOSE=1; args=("${args[@]:1}");; -prefix) BUILD_PREFIX="${args[1]}"; args=("${args[@]:2}");; -i | -infix) BUILD_INFIX="${args[1]}"; args=("${args[@]:2}");; - -t | -type) BUILD_TYPE="${args[1]}"; args=("${args[@]:2}");; + -d | -debug) DEBUG_BUILD=1; args=("${args[@]:1}");; + -c | -clean) CLEAN_BUILD=1; args=("${args[@]:1}");; -cuda) CUDA_COMPILER="${args[1]}"; args=("${args[@]:2}");; -cxx) HOST_COMPILER="${args[1]}"; args=("${args[@]:2}");; -arch) CUDA_ARCHS="${args[1]}"; args=("${args[@]:2}");; @@ -88,13 +91,18 @@ fi set -u if [ "$BUILD_INFIX" = "latest" ] || [ -z "$BUILD_INFIX" ]; then - echo "Error: BUILD_INFIX cannot be 'latest'" >&2 + echo "Error: BUILD_INFIX cannot be empty or 'latest'" >&2 exit 1 fi +# Trigger clean (re-)build +if [ "${CLEAN_BUILD:-0}" -eq 1 ]; then + rm -rf BUILD_DIR +fi + BUILD_DIR="$BUILD_PREFIX/$BUILD_INFIX" -export BUILD_DIR # TODO remove mkdir -p $BUILD_DIR +export BUILD_DIR # TODO remove # The most recent build will be symlinked to cuCollections/build/latest rm -f $BUILD_PREFIX/latest @@ -104,6 +112,8 @@ ln -sf $BUILD_DIR $BUILD_PREFIX/latest # Now that BUILD_DIR exists, use readlink to canonicalize the path: BUILD_DIR=$(readlink -f "${BUILD_DIR}") +BUILD_TYPE=$( [ "$DEBUG_BUILD" -eq 1 ] && echo "Debug" || echo "Release" ) + CMAKE_OPTIONS=" -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ -DCMAKE_CXX_STANDARD=${CXX_STANDARD} \ @@ -120,6 +130,7 @@ echo "-- START: $(date)" echo "-- GIT_SHA: $(git rev-parse HEAD 2>/dev/null || echo 'Not a repository')" echo "-- PWD: $(pwd)" echo "-- BUILD_DIR: ${BUILD_DIR}" +echo "-- BUILD_TYPE: ${BUILD_TYPE}" echo "-- PARALLEL_LEVEL: ${PARALLEL_LEVEL}" echo "-- CUDA_ARCHS: ${CUDA_ARCHS}"