@@ -39,15 +39,15 @@ update_devcontainer() {
3939
4040 # NVHPC SDK comes with its own bundled toolkit
4141 local toolkit_name=" -cuda${cuda_version}${cuda_suffix} "
42- if [ $compiler_name == " nvhpc" ]; then
42+ if [[ " $compiler_name " == " nvhpc" ] ]; then
4343 toolkit_name=" "
4444 fi
4545
4646 local IMAGE_ROOT=" rapidsai/devcontainers:${devcontainer_version} -cpp-"
4747 local INTERNAL_ROOT=" gitlab-master.nvidia.com:5005/cccl/cccl-devcontainers:cpp-"
4848
4949 img=$IMAGE_ROOT
50- if [ " $internal " == " true" ]; then
50+ if [[ " $internal " == " true" ] ]; then
5151 img=$INTERNAL_ROOT
5252 fi ;
5353
@@ -111,43 +111,55 @@ MATRIX_FILE="../ci/matrix.yaml"
111111COMPUTE_MATRIX=" ../.github/actions/workflow-build/build-workflow.py"
112112
113113# Enable verbose mode if requested
114- if [ " $VERBOSE " = true ]; then
114+ if [[ " $VERBOSE " = true ] ]; then
115115 set -x
116- cat ${MATRIX_FILE}
116+ cat " ${MATRIX_FILE} "
117117fi
118118
119119# Read matrix.yaml and convert it to json
120- matrix_json=$( python3 ${COMPUTE_MATRIX} ${MATRIX_FILE} --devcontainer-info)
120+ matrix_json=$( python3 " ${COMPUTE_MATRIX} " " ${MATRIX_FILE} " --devcontainer-info)
121121
122- if [ " $VERBOSE " = true ]; then
122+ if [[ " $VERBOSE " = true ] ]; then
123123 echo " $matrix_json "
124124fi
125125
126126# Get the devcontainer image version and define image tag root
127- readonly DEVCONTAINER_VERSION=$( echo " $matrix_json " | jq -r ' .devcontainer_version' )
127+ DEVCONTAINER_VERSION=$( echo " $matrix_json " | jq -r ' .devcontainer_version' )
128+ readonly DEVCONTAINER_VERSION
128129
129130# Internal image compiler versions:
130- readonly CUDA99_GCC_VERSION=$( echo " $matrix_json " | jq -r ' .cuda99_gcc_version' )
131- readonly CUDA99_LLVM_VERSION=$( echo " $matrix_json " | jq -r ' .cuda99_clang_version' )
131+ CUDA99_GCC_VERSION=$( echo " $matrix_json " | jq -r ' .cuda99_gcc_version' )
132+ readonly CUDA99_GCC_VERSION
133+ CUDA99_LLVM_VERSION=$( echo " $matrix_json " | jq -r ' .cuda99_clang_version' )
134+ readonly CUDA99_LLVM_VERSION
132135
133136# Get unique combinations of cuda version, compiler name/version, and Ubuntu version
134- readonly combinations=$( echo " $matrix_json " | jq -c ' .combinations[]' )
137+ combinations=$( echo " $matrix_json " | jq -c ' .combinations[]' )
138+ readonly combinations
135139
136140# Update the base devcontainer with the default values
137141# The root devcontainer.json file is used as the default container as well as a template for all
138142# other devcontainer.json files by replacing the `image:` field with the appropriate image name
139143readonly base_devcontainer_file=" ./devcontainer.json"
140- readonly NEWEST_GCC_CUDA_ENTRY=$( echo " $combinations " | jq -rs ' [.[] | select(.compiler_name == "gcc")] | sort_by((.cuda | tonumber), (.compiler_version | tonumber)) | .[-1]' )
141- readonly NEWEST_LLVM_CUDA_ENTRY=$( echo " $combinations " | jq -rs ' [.[] | select(.compiler_name == "llvm")] | sort_by((.cuda | tonumber), (.compiler_version | tonumber)) | .[-1]' )
142- readonly DEFAULT_CUDA=$( echo " $NEWEST_GCC_CUDA_ENTRY " | jq -r ' .cuda' )
144+ NEWEST_GCC_CUDA_ENTRY=$( echo " $combinations " | jq -rs ' [.[] | select(.compiler_name == "gcc")] | sort_by((.cuda | tonumber), (.compiler_version | tonumber)) | .[-1]' )
145+ readonly NEWEST_GCC_CUDA_ENTRY
146+ NEWEST_LLVM_CUDA_ENTRY=$( echo " $combinations " | jq -rs ' [.[] | select(.compiler_name == "llvm")] | sort_by((.cuda | tonumber), (.compiler_version | tonumber)) | .[-1]' )
147+ # shellcheck disable=SC2034
148+ readonly NEWEST_LLVM_CUDA_ENTRY
149+ DEFAULT_CUDA=$( echo " $NEWEST_GCC_CUDA_ENTRY " | jq -r ' .cuda' )
150+ readonly DEFAULT_CUDA
143151readonly DEFAULT_CUDA_EXT=false
144- readonly DEFAULT_COMPILER_NAME=$( echo " $NEWEST_GCC_CUDA_ENTRY " | jq -r ' .compiler_name' )
145- readonly DEFAULT_COMPILER_EXE=$( echo " $NEWEST_GCC_CUDA_ENTRY " | jq -r ' .compiler_exe' )
146- readonly DEFAULT_COMPILER_VERSION=$( echo " $NEWEST_GCC_CUDA_ENTRY " | jq -r ' .compiler_version' )
147- readonly DEFAULT_NAME=$( make_name " $DEFAULT_CUDA " " $DEFAULT_CUDA_EXT " " $DEFAULT_COMPILER_NAME " " $DEFAULT_COMPILER_VERSION " )
148-
149- update_devcontainer ${base_devcontainer_file} " ./temp_devcontainer.json" " $DEFAULT_NAME " " $DEFAULT_CUDA " " $DEFAULT_CUDA_EXT " " $DEFAULT_COMPILER_NAME " " $DEFAULT_COMPILER_EXE " " $DEFAULT_COMPILER_VERSION " " $DEVCONTAINER_VERSION " " false"
150- mv " ./temp_devcontainer.json" ${base_devcontainer_file}
152+ DEFAULT_COMPILER_NAME=$( echo " $NEWEST_GCC_CUDA_ENTRY " | jq -r ' .compiler_name' )
153+ readonly DEFAULT_COMPILER_NAME
154+ DEFAULT_COMPILER_EXE=$( echo " $NEWEST_GCC_CUDA_ENTRY " | jq -r ' .compiler_exe' )
155+ readonly DEFAULT_COMPILER_EXE
156+ DEFAULT_COMPILER_VERSION=$( echo " $NEWEST_GCC_CUDA_ENTRY " | jq -r ' .compiler_version' )
157+ readonly DEFAULT_COMPILER_VERSION
158+ DEFAULT_NAME=$( make_name " $DEFAULT_CUDA " " $DEFAULT_CUDA_EXT " " $DEFAULT_COMPILER_NAME " " $DEFAULT_COMPILER_VERSION " )
159+ readonly DEFAULT_NAME
160+
161+ update_devcontainer " ${base_devcontainer_file} " " ./temp_devcontainer.json" " $DEFAULT_NAME " " $DEFAULT_CUDA " " $DEFAULT_CUDA_EXT " " $DEFAULT_COMPILER_NAME " " $DEFAULT_COMPILER_EXE " " $DEFAULT_COMPILER_VERSION " " $DEVCONTAINER_VERSION " " false"
162+ mv " ./temp_devcontainer.json" " ${base_devcontainer_file} "
151163
152164# Create an array to keep track of valid subdirectory names
153165valid_subdirs=()
@@ -178,10 +190,14 @@ make_compiler_entry() {
178190 }" | jq -c ' .'
179191}
180192
181- readonly cuda99_8_gcc=$( make_compiler_entry " gcc" " $CUDA99_GCC_VERSION " " gcc" " 99.8" " false" " true" )
182- readonly cuda99_9_gcc=$( make_compiler_entry " gcc" " $CUDA99_GCC_VERSION " " gcc" " 99.9" " false" " true" )
183- readonly cuda99_8_llvm=$( make_compiler_entry " llvm" " $CUDA99_LLVM_VERSION " " clang" " 99.8" " false" " true" )
184- readonly cuda99_9_llvm=$( make_compiler_entry " llvm" " $CUDA99_LLVM_VERSION " " clang" " 99.9" " false" " true" )
193+ cuda99_8_gcc=$( make_compiler_entry " gcc" " $CUDA99_GCC_VERSION " " gcc" " 99.8" " false" " true" )
194+ readonly cuda99_8_gcc
195+ cuda99_9_gcc=$( make_compiler_entry " gcc" " $CUDA99_GCC_VERSION " " gcc" " 99.9" " false" " true" )
196+ readonly cuda99_9_gcc
197+ cuda99_8_llvm=$( make_compiler_entry " llvm" " $CUDA99_LLVM_VERSION " " clang" " 99.8" " false" " true" )
198+ readonly cuda99_8_llvm
199+ cuda99_9_llvm=$( make_compiler_entry " llvm" " $CUDA99_LLVM_VERSION " " clang" " 99.9" " false" " true" )
200+ readonly cuda99_9_llvm
185201
186202readonly all_comb=" $combinations $cuda99_9_gcc $cuda99_8_gcc $cuda99_9_llvm $cuda99_8_llvm "
187203# For each unique combination
@@ -205,9 +221,9 @@ for combination in $all_comb; do
205221done
206222
207223# Clean up stale subdirectories and devcontainer.json files
208- if [ " $CLEAN " = true ]; then
224+ if [[ " $CLEAN " = true ] ]; then
209225 for subdir in ./* ; do
210- if [ -d " $subdir " ] && [[ ! " ${valid_subdirs[@ ]} " =~ " ${subdir# ./ } " ]]; then
226+ if [[ -d " $subdir " ]] && [[ " ${valid_subdirs[* ]} " != * " ${subdir# ./ } " * ]]; then
211227 echo " Removing stale subdirectory: $subdir "
212228 rm -r " $subdir "
213229 fi
0 commit comments