Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions cc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,6 @@ unset IFS
# NOTE: Depending on your editor this may look empty, but it is not.
readonly lsep=''

# This is an array of environment variables that need to be set before
# the script runs. They are set by routines in spack.build_environment
# as part of the package installation process.
readonly params="\
SPACK_COMPILER_WRAPPER_PATH
SPACK_DEBUG_LOG_DIR
SPACK_DEBUG_LOG_ID
SPACK_SHORT_SPEC
SPACK_SYSTEM_DIRS
SPACK_MANAGED_DIRS"

# Optional parameters that aren't required to be set

# Boolean (true/false/custom) if we want to add debug flags
Expand Down Expand Up @@ -212,12 +201,13 @@ if eval "[ \"\${*#*${lsep}}\" != \"\$*\" ]"; then
die "Compiler command line contains our separator ('${lsep}'). Cannot parse."
fi

# ensure required variables are set
for param in $params; do
if eval "test -z \"\${${param}:-}\""; then
die "Spack compiler must be run from Spack! Input '$param' is missing."
fi
done
# Ensure required variables are set
: "${SPACK_COMPILER_WRAPPER_PATH:?Error: the compiler wrapper must be invoked from Spack}"
: "${SPACK_DEBUG_LOG_DIR:?Error: the compiler wrapper must be invoked from Spack}"
: "${SPACK_DEBUG_LOG_ID:?Error: the compiler wrapper must be invoked from Spack}"
: "${SPACK_SHORT_SPEC:?Error: the compiler wrapper must be invoked from Spack}"
: "${SPACK_SYSTEM_DIRS:?Error: the compiler wrapper must be invoked from Spack}"
: "${SPACK_MANAGED_DIRS:?Error: the compiler wrapper must be invoked from Spack}"

# eval this because SPACK_MANAGED_DIRS and SPACK_SYSTEM_DIRS are inputs we don't wanna loop over.
# moving the eval inside the function would eval it every call.
Expand Down
4 changes: 2 additions & 2 deletions test/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ test_no_wrapper_environment() {
fail "cc with no env unexpectedly exited 0"
fi
case "$_out" in
*"Spack compiler must be run from Spack"*) ;;
*) fail "expected 'Spack compiler must be run from Spack' in: $_out" ;;
*"compiler wrapper must be invoked from Spack"*) ;;
*) fail "expected 'compiler wrapper must be invoked from Spack' in: $_out" ;;
esac
}

Expand Down