@@ -37,6 +37,9 @@ resolve_path() {
3737# Ensure the script is being executed in its containing directory
3838cd " $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) " ;
3939
40+ # Determine repo root as the parent of the `ci` directory
41+ REPO_ROOT=" $( cd .. && pwd) "
42+
4043# Script defaults
4144BUILD_TESTS=${BUILD_TESTS:- OFF}
4245BUILD_EXAMPLES=${BUILD_EXAMPLES:- OFF}
@@ -51,6 +54,13 @@ HOST_COMPILER=${CXX:-g++} # $CXX if set, otherwise `g++`
5154CUDA_ARCHS=native # detect system's GPU architectures
5255CXX_STANDARD=17
5356
57+ # Initialize CMAKE_ARGS from environment variable if available
58+ if [ -n " ${CMAKE_ARGS:- } " ]; then
59+ read -ra CMAKE_ARGS <<< " $CMAKE_ARGS"
60+ else
61+ CMAKE_ARGS=()
62+ fi
63+
5464function usage {
5565 echo " cuCollections build script"
5666 echo " Usage: $0 [OPTIONS]"
@@ -62,9 +72,9 @@ function usage {
6272 echo " --prefix: Build directory prefix (Defaults to <repo_root>/build)"
6373 echo " -i/--infix: Build directory infix (Defaults to local)"
6474 echo " -d/--debug: Debug build"
65- echo " -p/--parallel: Build parallelism (Defaults to \ $ PARALLEL_LEVEL if set, otherwise the system's number of CPU cores)"
66- echo " --cuda: CUDA compiler (Defaults to \ $ CUDACXX if set, otherwise nvcc)"
67- echo " --cxx: Host compiler (Defaults to \ $ CXX if set, otherwise g++)"
75+ echo " -p/--parallel: Build parallelism (Defaults to $PARALLEL_LEVEL if set, otherwise the system's number of CPU cores)"
76+ echo " --cuda: CUDA compiler (Defaults to $CUDACXX if set, otherwise nvcc)"
77+ echo " --cxx: Host compiler (Defaults to $CXX if set, otherwise g++)"
6878 echo " --arch: Target CUDA arches, e.g. \" 60-real;70;80-virtual\" (Defaults to the system's native GPU archs)"
6979 echo " --std: CUDA/C++ standard (Defaults to 17)"
7080 echo " -v/-verbose/--verbose: Enable shell echo for debugging"
@@ -103,6 +113,16 @@ function usage {
103113 echo " Enables verbose mode for detailed output and builds with C++17 standard."
104114 echo " Build files will be written to <repo_root>/build/local and symlinked to <repo_root>/build/latest."
105115 echo
116+ echo " Using CMAKE_ARGS Environment Variable:"
117+ echo " $ CMAKE_ARGS=\" -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_FEATURE=ON\" $0 -t"
118+ echo " $ export CMAKE_ARGS=\" -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_FEATURE=ON\" "
119+ echo " $ $0 -t"
120+ echo " Uses CMAKE_ARGS environment variable to pass additional CMake options."
121+ echo " Can be overridden by using -- followed by specific arguments."
122+ echo
123+ echo " Pass-through to CMake:"
124+ echo " -- [CMake args...] Anything after -- is forwarded to CMake (overrides CMAKE_ARGS env var)"
125+ echo
106126 exit 1
107127}
108128
@@ -126,6 +146,7 @@ while [ "${#args[@]}" -ne 0 ]; do
126146 --arch) CUDA_ARCHS=" ${args[1]} " ; args=(" ${args[@]: 2} " );;
127147 --std) CXX_STANDARD=" ${args[1]} " ; args=(" ${args[@]: 2} " );;
128148 -v | -verbose | --verbose) VERBOSE=1; args=(" ${args[@]: 1} " );;
149+ --) CMAKE_ARGS=(" ${args[@]: 1} " ); break ;;
129150 -h | -help | --help) usage ;;
130151 * ) echo " Unrecognized option: ${args[0]} " ; usage ;;
131152 esac
@@ -156,14 +177,12 @@ if [ "$BUILD_TESTS" == "OFF" ] && [ "$BUILD_EXAMPLES" == "OFF" ] && [ "$BUILD_BE
156177 BUILD_BENCHMARKS=ON
157178fi
158179
180+ BUILD_DIR=" $BUILD_PREFIX /$BUILD_INFIX "
159181# Trigger clean (re-)build
160182if [ " $CLEAN_BUILD " -eq 1 ]; then
161183 rm -rf BUILD_DIR
162184fi
163-
164- BUILD_DIR=" $BUILD_PREFIX /$BUILD_INFIX "
165185mkdir -p $BUILD_DIR
166- export BUILD_DIR # TODO remove
167186
168187# The most recent build will be symlinked to cuCollections/build/latest
169188rm -f $BUILD_PREFIX /latest
@@ -188,10 +207,10 @@ CMAKE_OPTIONS="
188207 -DBUILD_BENCHMARKS=${BUILD_BENCHMARKS} \
189208"
190209
191- echo " ========================================"
192- echo " -- START : $( date) "
210+ echo " [INFO]====== ========================================"
211+ echo " -- TIMESTAMP : $( date -u + " %Y-%m-%d %H:%M:%S UTC " ) "
193212echo " -- GIT_SHA: $( git rev-parse HEAD 2> /dev/null || echo ' Not a repository' ) "
194- echo " -- PWD : $( pwd ) "
213+ echo " -- SRC_DIR : ${REPO_ROOT} "
195214echo " -- BUILD_DIR: ${BUILD_DIR} "
196215echo " -- BUILD_TYPE: ${BUILD_TYPE} "
197216echo " -- PARALLEL_LEVEL: ${PARALLEL_LEVEL} "
@@ -200,21 +219,30 @@ echo "-- BUILD_TESTS: ${BUILD_TESTS}"
200219echo " -- BUILD_EXAMPLES: ${BUILD_EXAMPLES} "
201220echo " -- BUILD_BENCHMARKS: ${BUILD_BENCHMARKS} "
202221
222+ if [ ${# CMAKE_ARGS[@]} -gt 0 ]; then
223+ echo " -- CMAKE_ARGS: ${CMAKE_ARGS[*]} "
224+ else
225+ echo " -- CMAKE_ARGS: (none)"
226+ fi
227+
228+
203229# configure
204- cmake -S .. -B $BUILD_DIR $CMAKE_OPTIONS
205- echo " ======================================== "
230+ echo " [CONFIGURE]======================================== "
231+ cmake -S .. -B $BUILD_DIR $CMAKE_OPTIONS " ${CMAKE_ARGS[@]} "
206232
207233if command -v sccache > /dev/null; then
208234 source " ./sccache_stats.sh" start
235+ else
236+ echo " sccache stats: N/A"
209237fi
210238
211239# build
240+ echo " [BUILD]============================================"
212241cmake --build $BUILD_DIR --parallel $PARALLEL_LEVEL
213- echo " ========================================"
214242echo " Build complete"
215243
216244if command -v sccache > /dev/null; then
217245 source " ./sccache_stats.sh" end
218246else
219247 echo " sccache stats: N/A"
220- fi
248+ fi
0 commit comments