@@ -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]"
@@ -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,29 @@ 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+
203228# configure
204- cmake -S .. -B $BUILD_DIR $CMAKE_OPTIONS
205- echo " ======================================== "
229+ echo " [CONFIGURE]======================================== "
230+ cmake -S .. -B $BUILD_DIR $CMAKE_OPTIONS " ${CMAKE_ARGS[@]} "
206231
207232if command -v sccache > /dev/null; then
208233 source " ./sccache_stats.sh" start
234+ else
235+ echo " sccache stats: N/A"
209236fi
210237
211238# build
239+ echo " [BUILD]============================================"
212240cmake --build $BUILD_DIR --parallel $PARALLEL_LEVEL
213- echo " ========================================"
214241echo " Build complete"
215242
216243if command -v sccache > /dev/null; then
217244 source " ./sccache_stats.sh" end
218245else
219246 echo " sccache stats: N/A"
220- fi
247+ fi
0 commit comments