2014-11-03 15:53:45 +08:00
|
|
|
#!/bin/bash
|
|
|
|
##############################################################################
|
|
|
|
# Copyright (c) 2013, Lawrence Livermore National Security, LLC.
|
|
|
|
# Produced at the Lawrence Livermore National Laboratory.
|
|
|
|
#
|
|
|
|
# This file is part of Spack.
|
|
|
|
# Written by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
|
|
|
# LLNL-CODE-647188
|
|
|
|
#
|
2015-12-09 17:24:15 +08:00
|
|
|
# For details, see https://github.com/llnl/spack
|
2014-11-03 15:53:45 +08:00
|
|
|
# Please also see the LICENSE file for our notice and the LGPL.
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License (as published by
|
|
|
|
# the Free Software Foundation) version 2.1 dated February 1999.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful, but
|
|
|
|
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
|
|
|
# conditions of the GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
|
|
|
# along with this program; if not, write to the Free Software Foundation,
|
|
|
|
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
##############################################################################
|
|
|
|
#
|
|
|
|
# Spack compiler wrapper script.
|
|
|
|
#
|
|
|
|
# Compiler commands go through this compiler wrapper in Spack builds.
|
|
|
|
# The compiler wrapper is a thin layer around the standard compilers.
|
|
|
|
# It enables several key pieces of functionality:
|
|
|
|
#
|
|
|
|
# 1. It allows Spack to swap compilers into and out of builds easily.
|
|
|
|
# 2. It adds several options to the compile line so that spack
|
|
|
|
# packages can find their dependencies at build time and run time:
|
|
|
|
# -I arguments for dependency /include directories.
|
|
|
|
# -L arguments for dependency /lib directories.
|
|
|
|
# -Wl,-rpath arguments for dependency /lib directories.
|
|
|
|
#
|
|
|
|
|
|
|
|
# This is the list of environment variables that need to be set before
|
|
|
|
# the script runs. They are set by routines in spack.build_environment
|
|
|
|
# as part of spack.package.Package.do_install().
|
|
|
|
parameters="
|
|
|
|
SPACK_PREFIX
|
|
|
|
SPACK_ENV_PATH
|
|
|
|
SPACK_DEBUG_LOG_DIR
|
|
|
|
SPACK_COMPILER_SPEC
|
|
|
|
SPACK_SHORT_SPEC"
|
|
|
|
|
|
|
|
# The compiler input variables are checked for sanity later:
|
|
|
|
# SPACK_CC, SPACK_CXX, SPACK_F77, SPACK_FC
|
|
|
|
# Debug flag is optional; set to true for debug logging:
|
|
|
|
# SPACK_DEBUG
|
|
|
|
# Test command is used to unit test the compiler script.
|
|
|
|
# SPACK_TEST_COMMAND
|
|
|
|
# Dependencies can be empty for pkgs with no deps:
|
|
|
|
# SPACK_DEPENDENCIES
|
|
|
|
|
|
|
|
# die()
|
|
|
|
# Prints a message and exits with error 1.
|
|
|
|
function die {
|
|
|
|
echo "$@"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
for param in $parameters; do
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ -z "${!param}" ]; then
|
2014-11-03 15:53:45 +08:00
|
|
|
die "Spack compiler must be run from spack! Input $param was missing!"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
#
|
|
|
|
# Figure out the type of compiler, the language, and the mode so that
|
|
|
|
# the compiler script knows what to do.
|
|
|
|
#
|
|
|
|
# Possible languages are C, C++, Fortran 77, and Fortran 90.
|
|
|
|
# 'command' is set based on the input command to $SPACK_[CC|CXX|F77|F90]
|
|
|
|
#
|
|
|
|
# 'mode' is set to one of:
|
|
|
|
# cc compile
|
|
|
|
# ld link
|
|
|
|
# ccld compile & link
|
|
|
|
# cpp preprocessor
|
|
|
|
# vcheck version check
|
|
|
|
#
|
|
|
|
command=$(basename "$0")
|
|
|
|
case "$command" in
|
Fix #254: libtool & distutils want certain compiler names.
This changes the compiler wrappers so that they are called by the same
name as the wrapped compiler. Many builds make assumptions about
compiler names, and we need the spack compilers to be recognizable so
that build systems will get their flags right.
This adds per-compiler subdirectories to lib/spack/spack/env directory
that contain symlinks to cc for the C, C++, F77, and F90
compilers. The build now sets CC, CXX, F77, and F90 to point to these
links instead of to the generically named cc, c++, f77, and f90
wrappers.
2015-12-19 18:06:47 +08:00
|
|
|
cc|c89|c99|gcc|clang|icc|pgcc|xlc)
|
2014-11-03 15:53:45 +08:00
|
|
|
command="$SPACK_CC"
|
|
|
|
language="C"
|
|
|
|
;;
|
2016-03-04 06:50:51 +08:00
|
|
|
c++|CC|g++|clang++|icpc|pgc++|xlc++)
|
2014-11-03 15:53:45 +08:00
|
|
|
command="$SPACK_CXX"
|
|
|
|
language="C++"
|
|
|
|
;;
|
2016-03-04 06:50:51 +08:00
|
|
|
f90|fc|f95|gfortran|ifort|pgfortran|xlf90|nagfor)
|
2014-11-03 15:53:45 +08:00
|
|
|
command="$SPACK_FC"
|
|
|
|
language="Fortran 90"
|
|
|
|
;;
|
2016-03-04 06:50:51 +08:00
|
|
|
f77|gfortran|ifort|pgfortran|xlf|nagfor)
|
Fix #254: libtool & distutils want certain compiler names.
This changes the compiler wrappers so that they are called by the same
name as the wrapped compiler. Many builds make assumptions about
compiler names, and we need the spack compilers to be recognizable so
that build systems will get their flags right.
This adds per-compiler subdirectories to lib/spack/spack/env directory
that contain symlinks to cc for the C, C++, F77, and F90
compilers. The build now sets CC, CXX, F77, and F90 to point to these
links instead of to the generically named cc, c++, f77, and f90
wrappers.
2015-12-19 18:06:47 +08:00
|
|
|
command="$SPACK_F77"
|
|
|
|
language="Fortran 77"
|
|
|
|
;;
|
2014-11-03 15:53:45 +08:00
|
|
|
cpp)
|
|
|
|
mode=cpp
|
|
|
|
;;
|
|
|
|
ld)
|
|
|
|
mode=ld
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
die "Unkown compiler: $command"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2016-02-23 23:57:19 +08:00
|
|
|
# If any of the arguments below is present then the mode is vcheck. In vcheck mode nothing is added in terms of extra search paths or libraries
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ -z "$mode" ]; then
|
2014-11-03 15:53:45 +08:00
|
|
|
for arg in "$@"; do
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ "$arg" = -v -o "$arg" = -V -o "$arg" = --version -o "$arg" = -dumpversion ]; then
|
|
|
|
mode=vcheck
|
|
|
|
break
|
2016-03-10 21:35:09 +08:00
|
|
|
fi
|
2016-02-23 23:57:19 +08:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Finish setting up the mode.
|
|
|
|
|
|
|
|
if [ -z "$mode" ]; then
|
|
|
|
mode=ccld
|
|
|
|
for arg in "$@"; do
|
|
|
|
if [ "$arg" = -E ]; then
|
2016-02-13 02:05:42 +08:00
|
|
|
mode=cpp
|
|
|
|
break
|
|
|
|
elif [ "$arg" = -c ]; then
|
|
|
|
mode=cc
|
|
|
|
break
|
|
|
|
fi
|
2014-11-03 15:53:45 +08:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2016-03-02 05:53:53 +08:00
|
|
|
# Dump the version and exit if we're in testing mode.
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ "$SPACK_TEST_COMMAND" = "dump-mode" ]; then
|
2014-11-03 15:53:45 +08:00
|
|
|
echo "$mode"
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check that at least one of the real commands was actually selected,
|
|
|
|
# otherwise we don't know what to execute.
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ -z "$command" ]; then
|
2014-11-03 15:53:45 +08:00
|
|
|
die "ERROR: Compiler '$SPACK_COMPILER_SPEC' does not support compiling $language programs."
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Save original command for debug logging
|
|
|
|
input_command="$@"
|
2015-12-21 23:21:33 +08:00
|
|
|
args=("$@")
|
2014-11-03 15:53:45 +08:00
|
|
|
|
2016-03-18 09:52:24 +08:00
|
|
|
<<<<<<< HEAD
|
2015-12-21 23:21:33 +08:00
|
|
|
# Dump parsed values for unit testing if asked for
|
|
|
|
if [[ -n $SPACK_TEST_COMMAND ]]; then
|
2014-11-03 15:53:45 +08:00
|
|
|
|
2015-12-21 23:21:33 +08:00
|
|
|
#
|
|
|
|
# Now do real parsing of the command line args, trying hard to keep
|
2016-02-13 02:05:42 +08:00
|
|
|
# non-rpath linker arguments in the proper order w.r.t. other command
|
|
|
|
# line arguments. This is important for things like groups.
|
2015-12-21 23:21:33 +08:00
|
|
|
#
|
|
|
|
includes=()
|
|
|
|
libraries=()
|
|
|
|
libs=()
|
|
|
|
rpaths=()
|
|
|
|
other_args=()
|
|
|
|
|
2016-02-13 02:05:42 +08:00
|
|
|
while [ -n "$1" ]; do
|
2015-12-21 23:21:33 +08:00
|
|
|
case "$1" in
|
|
|
|
-I*)
|
|
|
|
arg="${1#-I}"
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ -z "$arg" ]; then shift; arg="$1"; fi
|
2015-12-21 23:21:33 +08:00
|
|
|
includes+=("$arg")
|
|
|
|
;;
|
|
|
|
-L*)
|
|
|
|
arg="${1#-L}"
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ -z "$arg" ]; then shift; arg="$1"; fi
|
2015-12-21 23:21:33 +08:00
|
|
|
libraries+=("$arg")
|
|
|
|
;;
|
|
|
|
-l*)
|
|
|
|
arg="${1#-l}"
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ -z "$arg" ]; then shift; arg="$1"; fi
|
2015-12-21 23:21:33 +08:00
|
|
|
libs+=("$arg")
|
|
|
|
;;
|
|
|
|
-Wl,*)
|
|
|
|
arg="${1#-Wl,}"
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ -z "$arg" ]; then shift; arg="$1"; fi
|
|
|
|
if [[ "$arg" = -rpath=* ]]; then
|
2015-12-21 23:21:33 +08:00
|
|
|
rpaths+=("${arg#-rpath=}")
|
2016-02-13 02:05:42 +08:00
|
|
|
elif [[ "$arg" = -rpath ]]; then
|
2015-12-21 23:21:33 +08:00
|
|
|
shift; arg="$1"
|
2016-02-13 02:05:42 +08:00
|
|
|
if [[ "$arg" != -Wl,* ]]; then
|
2015-12-21 23:21:33 +08:00
|
|
|
die "-Wl,-rpath was not followed by -Wl,*"
|
|
|
|
fi
|
|
|
|
rpaths+=("${arg#-Wl,}")
|
|
|
|
else
|
|
|
|
other_args+=("-Wl,$arg")
|
2014-11-03 15:53:45 +08:00
|
|
|
fi
|
2015-12-21 23:21:33 +08:00
|
|
|
;;
|
|
|
|
-Xlinker,*)
|
|
|
|
arg="${1#-Xlinker,}"
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ -z "$arg" ]; then shift; arg="$1"; fi
|
|
|
|
if [[ "$arg" = -rpath=* ]]; then
|
2015-12-21 23:21:33 +08:00
|
|
|
rpaths+=("${arg#-rpath=}")
|
2016-02-13 02:05:42 +08:00
|
|
|
elif [[ "$arg" = -rpath ]]; then
|
2015-12-21 23:21:33 +08:00
|
|
|
shift; arg="$1"
|
2016-02-13 02:05:42 +08:00
|
|
|
if [[ "$arg" != -Xlinker,* ]]; then
|
2015-12-21 23:21:33 +08:00
|
|
|
die "-Xlinker,-rpath was not followed by -Xlinker,*"
|
|
|
|
fi
|
|
|
|
rpaths+=("${arg#-Xlinker,}")
|
|
|
|
else
|
|
|
|
other_args+=("-Xlinker,$arg")
|
2014-11-03 15:53:45 +08:00
|
|
|
fi
|
2015-12-21 23:21:33 +08:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
other_args+=("$1")
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2016-03-18 09:52:24 +08:00
|
|
|
=======
|
2016-02-23 23:57:19 +08:00
|
|
|
if [ "$mode" == vcheck ] ; then
|
2016-03-10 21:59:31 +08:00
|
|
|
exec ${command} "$@"
|
2016-02-23 23:57:19 +08:00
|
|
|
fi
|
|
|
|
|
2014-11-03 15:53:45 +08:00
|
|
|
#
|
|
|
|
# Now do real parsing of the command line args, trying hard to keep
|
|
|
|
# non-rpath linker arguments in the proper order w.r.t. other command
|
|
|
|
# line arguments. This is important for things like groups.
|
|
|
|
#
|
|
|
|
includes=()
|
|
|
|
libraries=()
|
|
|
|
libs=()
|
|
|
|
rpaths=()
|
|
|
|
other_args=()
|
|
|
|
|
|
|
|
while [ -n "$1" ]; do
|
|
|
|
case "$1" in
|
|
|
|
-I*)
|
|
|
|
arg="${1#-I}"
|
|
|
|
if [ -z "$arg" ]; then shift; arg="$1"; fi
|
|
|
|
includes+=("$arg")
|
|
|
|
;;
|
|
|
|
-L*)
|
|
|
|
arg="${1#-L}"
|
|
|
|
if [ -z "$arg" ]; then shift; arg="$1"; fi
|
|
|
|
libraries+=("$arg")
|
|
|
|
;;
|
|
|
|
-l*)
|
|
|
|
arg="${1#-l}"
|
|
|
|
if [ -z "$arg" ]; then shift; arg="$1"; fi
|
|
|
|
libs+=("$arg")
|
|
|
|
;;
|
|
|
|
-Wl,*)
|
|
|
|
arg="${1#-Wl,}"
|
2016-02-14 23:43:55 +08:00
|
|
|
# TODO: Handle multiple -Wl, continuations of -Wl,-rpath
|
2016-03-03 23:40:06 +08:00
|
|
|
if [[ $arg == -rpath=* ]]; then
|
2016-02-13 01:09:29 +08:00
|
|
|
arg="${arg#-rpath=}"
|
|
|
|
for rpath in ${arg//,/ }; do
|
|
|
|
rpaths+=("$rpath")
|
|
|
|
done
|
2016-03-03 23:40:06 +08:00
|
|
|
elif [[ $arg == -rpath,* ]]; then
|
2016-02-13 01:37:03 +08:00
|
|
|
arg="${arg#-rpath,}"
|
|
|
|
for rpath in ${arg//,/ }; do
|
2016-02-14 11:01:36 +08:00
|
|
|
rpaths+=("$rpath")
|
2016-02-13 01:37:03 +08:00
|
|
|
done
|
2016-03-03 23:40:06 +08:00
|
|
|
elif [[ $arg == -rpath ]]; then
|
2014-11-03 15:53:45 +08:00
|
|
|
shift; arg="$1"
|
2016-02-15 00:34:08 +08:00
|
|
|
if [[ $arg != '-Wl,'* ]]; then
|
2014-11-03 15:53:45 +08:00
|
|
|
die "-Wl,-rpath was not followed by -Wl,*"
|
|
|
|
fi
|
2016-02-13 01:09:29 +08:00
|
|
|
arg="${arg#-Wl,}"
|
|
|
|
for rpath in ${arg//,/ }; do
|
|
|
|
rpaths+=("$rpath")
|
|
|
|
done
|
2014-11-03 15:53:45 +08:00
|
|
|
else
|
|
|
|
other_args+=("-Wl,$arg")
|
|
|
|
fi
|
|
|
|
;;
|
2016-03-07 17:08:08 +08:00
|
|
|
-Xlinker)
|
|
|
|
shift; arg="$1";
|
2016-02-13 01:09:29 +08:00
|
|
|
if [[ $arg = -rpath=* ]]; then
|
2014-11-03 15:53:45 +08:00
|
|
|
rpaths+=("${arg#-rpath=}")
|
2016-02-13 01:09:29 +08:00
|
|
|
elif [[ $arg = -rpath ]]; then
|
2014-11-03 15:53:45 +08:00
|
|
|
shift; arg="$1"
|
2016-03-07 17:08:08 +08:00
|
|
|
if [[ $arg != -Xlinker ]]; then
|
|
|
|
die "-Xlinker -rpath was not followed by -Xlinker <arg>"
|
2014-11-03 15:53:45 +08:00
|
|
|
fi
|
2016-03-07 17:08:08 +08:00
|
|
|
shift; arg="$1"
|
|
|
|
rpaths+=("$arg")
|
2014-11-03 15:53:45 +08:00
|
|
|
else
|
2016-03-07 17:08:08 +08:00
|
|
|
other_args+=("-Xlinker")
|
|
|
|
other_args+=("$arg")
|
2014-11-03 15:53:45 +08:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
other_args+=("$1")
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2016-03-18 09:52:24 +08:00
|
|
|
>>>>>>> develop
|
2014-11-03 15:53:45 +08:00
|
|
|
|
|
|
|
IFS=$'\n'
|
|
|
|
case "$SPACK_TEST_COMMAND" in
|
|
|
|
dump-includes) echo "${includes[*]}";;
|
|
|
|
dump-libraries) echo "${libraries[*]}";;
|
|
|
|
dump-libs) echo "${libs[*]}";;
|
|
|
|
dump-rpaths) echo "${rpaths[*]}";;
|
|
|
|
dump-other-args) echo "${other_args[*]}";;
|
|
|
|
dump-all)
|
|
|
|
echo "INCLUDES:"
|
|
|
|
echo "${includes[*]}"
|
|
|
|
echo
|
|
|
|
echo "LIBRARIES:"
|
|
|
|
echo "${libraries[*]}"
|
|
|
|
echo
|
|
|
|
echo "LIBS:"
|
|
|
|
echo "${libs[*]}"
|
|
|
|
echo
|
|
|
|
echo "RPATHS:"
|
|
|
|
echo "${rpaths[*]}"
|
|
|
|
echo
|
|
|
|
echo "ARGS:"
|
|
|
|
echo "${other_args[*]}"
|
|
|
|
;;
|
|
|
|
*)
|
2016-02-13 02:05:42 +08:00
|
|
|
echo "ERROR: Unknown test command"
|
|
|
|
exit 1 ;;
|
2014-11-03 15:53:45 +08:00
|
|
|
esac
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Read spack dependencies from the path environment variable
|
|
|
|
IFS=':' read -ra deps <<< "$SPACK_DEPENDENCIES"
|
|
|
|
for dep in "${deps[@]}"; do
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ -d "$dep/include" ]; then
|
2015-12-21 23:21:33 +08:00
|
|
|
args=("-I$dep/include" "${args[@]}")
|
2014-11-03 15:53:45 +08:00
|
|
|
fi
|
|
|
|
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ -d "$dep/lib" ]; then
|
2015-12-23 04:49:14 +08:00
|
|
|
if [[ $mode = ccld ]]; then
|
2015-12-21 23:21:33 +08:00
|
|
|
args=("-L$dep/lib" "-Wl,-rpath,$dep/lib" "${args[@]}")
|
|
|
|
elif [[ $mode = ld ]]; then
|
|
|
|
args=("-L$dep/lib" "-rpath" "$dep/lib" "${args[@]}")
|
|
|
|
fi
|
2014-11-03 15:53:45 +08:00
|
|
|
fi
|
|
|
|
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ -d "$dep/lib64" ]; then
|
2015-12-21 23:21:33 +08:00
|
|
|
# libraries+=("$dep/lib64")
|
|
|
|
if [[ $mode = ccld ]]; then
|
|
|
|
args=("-L$dep/lib" "-Wl,-rpath,$dep/lib" "${args[@]}")
|
|
|
|
elif [[ $mode = ld ]]; then
|
|
|
|
args=("-L$dep/lib" "-rpath" "$dep/lib" "${args[@]}")
|
|
|
|
fi
|
2014-11-03 15:53:45 +08:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
# Include all -L's and prefix/whatever dirs in rpath
|
2015-12-21 23:21:33 +08:00
|
|
|
if [[ $mode = ccld ]]; then
|
2015-12-23 04:49:14 +08:00
|
|
|
args=("-Wl,-rpath,$SPACK_PREFIX/lib" "-Wl,-rpath,$SPACK_PREFIX/lib64" "${args[@]}")
|
2015-12-21 23:21:33 +08:00
|
|
|
elif [[ $mode = ld ]]; then
|
2015-12-23 04:49:14 +08:00
|
|
|
args=("-rpath" "$SPACK_PREFIX/lib" "-rpath" "$SPACK_PREFIX/lib64" "${args[@]}")
|
2014-11-03 15:53:45 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Unset pesky environment variables that could affect build sanity.
|
|
|
|
#
|
|
|
|
unset LD_LIBRARY_PATH
|
|
|
|
unset LD_RUN_PATH
|
|
|
|
unset DYLD_LIBRARY_PATH
|
|
|
|
|
|
|
|
#
|
|
|
|
# Filter '.' and Spack environment directories out of PATH so that
|
|
|
|
# this script doesn't just call itself
|
|
|
|
#
|
|
|
|
IFS=':' read -ra env_path <<< "$PATH"
|
|
|
|
IFS=':' read -ra spack_env_dirs <<< "$SPACK_ENV_PATH"
|
2015-12-21 23:21:33 +08:00
|
|
|
spack_env_dirs+=("" ".")
|
2014-11-03 15:53:45 +08:00
|
|
|
PATH=""
|
|
|
|
for dir in "${env_path[@]}"; do
|
|
|
|
remove=""
|
|
|
|
for rm_dir in "${spack_env_dirs[@]}"; do
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ "$dir" = "$rm_dir" ]; then remove=True; fi
|
2014-11-03 15:53:45 +08:00
|
|
|
done
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ -z "$remove" ]; then
|
|
|
|
if [ -z "$PATH" ]; then
|
|
|
|
PATH="$dir"
|
|
|
|
else
|
|
|
|
PATH="$PATH:$dir"
|
|
|
|
fi
|
2014-11-03 15:53:45 +08:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
export PATH
|
|
|
|
|
2016-02-13 02:05:42 +08:00
|
|
|
full_command=("$command")
|
|
|
|
full_command+=("${args[@]}")
|
2014-11-03 15:53:45 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# Write the input and output commands to debug logs if it's asked for.
|
|
|
|
#
|
2016-02-13 02:05:42 +08:00
|
|
|
if [ "$SPACK_DEBUG" = "TRUE" ]; then
|
2014-11-03 15:53:45 +08:00
|
|
|
input_log="$SPACK_DEBUG_LOG_DIR/spack-cc-$SPACK_SHORT_SPEC.in.log"
|
|
|
|
output_log="$SPACK_DEBUG_LOG_DIR/spack-cc-$SPACK_SHORT_SPEC.out.log"
|
2016-02-13 02:05:42 +08:00
|
|
|
echo "$input_command" >> $input_log
|
2014-11-03 15:53:45 +08:00
|
|
|
echo "$mode ${full_command[@]}" >> $output_log
|
|
|
|
fi
|
|
|
|
|
|
|
|
exec "${full_command[@]}"
|