diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2018-08-06 10:55:27 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2018-08-08 01:51:51 -0700 |
commit | 62089d43ef5e37b7fdbb12247edc1e0bf30cc657 (patch) | |
tree | 75a558b0230340651b6eac07b6cc06faa7a15c54 /lib | |
parent | b84067f6db52acbc9080bb741a8075c754431e98 (diff) | |
download | spack-62089d43ef5e37b7fdbb12247edc1e0bf30cc657.tar.gz spack-62089d43ef5e37b7fdbb12247edc1e0bf30cc657.tar.bz2 spack-62089d43ef5e37b7fdbb12247edc1e0bf30cc657.tar.xz spack-62089d43ef5e37b7fdbb12247edc1e0bf30cc657.zip |
cc: run shellcheck linter on the cc compiler script, minor cleanup
- This corrects most of the issues found by shellcheck
- This also uses ':' as the delimiter for SPACK_SYSTEM_DIRS, for
consistency with other variables.
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/spack/env/cc | 24 | ||||
-rw-r--r-- | lib/spack/spack/build_environment.py | 2 |
2 files changed, 14 insertions, 12 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc index f056f0f98e..5ffaf941e0 100755 --- a/lib/spack/env/cc +++ b/lib/spack/env/cc @@ -74,11 +74,14 @@ function die { exit 1 } +# read system directories into an array (delimited by :) +IFS=':' read -ra SPACK_SYSTEM_DIRS <<< "${SPACK_SYSTEM_DIRS}" + # test whether a path is a system directory function system_dir { path="$1" for sd in ${SPACK_SYSTEM_DIRS[@]}; do - if [ "${path}" == "${sd}" -o "${path}" == "${sd}/" ]; then + if [ "${path}" == "${sd}" ] || [ "${path}" == "${sd}/" ]; then # success if path starts with a system prefix return 0 fi @@ -130,7 +133,7 @@ case "$command" in comp="FC" lang_flags=F ;; - f77|gfortran|flang|ifort|pgfortran|xlf|xlf_r|nagfor|ftn) + f77|xlf|xlf_r|pgf77) command="$SPACK_F77" language="Fortran 77" comp="F77" @@ -198,8 +201,8 @@ fi IFS=':' read -ra env_set_varnames <<< "$SPACK_ENV_TO_SET" for varname in "${env_set_varnames[@]}"; do spack_varname="SPACK_ENV_SET_$varname" - export $varname=${!spack_varname} - unset $spack_varname + export "$varname"="${!spack_varname}" + unset "$spack_varname" done # @@ -209,23 +212,22 @@ done IFS=':' read -ra env_path <<< "$PATH" IFS=':' read -ra spack_env_dirs <<< "$SPACK_ENV_PATH" spack_env_dirs+=("" ".") -PATH="" +export PATH="" for dir in "${env_path[@]}"; do addpath=true for env_dir in "${spack_env_dirs[@]}"; do - if [[ $dir == $env_dir ]]; then + if [[ "$dir" == "$env_dir" ]]; then addpath=false break fi done if $addpath; then - PATH="${PATH:+$PATH:}$dir" + export PATH="${PATH:+$PATH:}$dir" fi done -export PATH if [[ $mode == vcheck ]]; then - exec ${command} "$@" + exec "${command}" "$@" fi # Darwin's linker has a -r argument that merges object files together. @@ -245,7 +247,7 @@ then fi # Save original command for debug logging -input_command="$@" +input_command="$*" args=() # @@ -497,7 +499,7 @@ if [[ $SPACK_DEBUG == TRUE ]]; then input_log="$SPACK_DEBUG_LOG_DIR/spack-cc-$SPACK_DEBUG_LOG_ID.in.log" output_log="$SPACK_DEBUG_LOG_DIR/spack-cc-$SPACK_DEBUG_LOG_ID.out.log" echo "[$mode] $command $input_command" >> "$input_log" - echo "[$mode] ${full_command[@]}" >> "$output_log" + echo "[$mode] ${full_command[*]}" >> "$output_log" fi exec "${full_command[@]}" diff --git a/lib/spack/spack/build_environment.py b/lib/spack/spack/build_environment.py index ea18cc87d0..01a5a9ed17 100644 --- a/lib/spack/spack/build_environment.py +++ b/lib/spack/spack/build_environment.py @@ -204,7 +204,7 @@ def set_compiler_environment_variables(pkg, env): env.set('SPACK_COMPILER_SPEC', str(pkg.spec.compiler)) - env.set('SPACK_SYSTEM_DIRS', ' '.join(system_dirs)) + env.set('SPACK_SYSTEM_DIRS', ':'.join(system_dirs)) compiler.setup_custom_environment(pkg, env) |