summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoralalazo <massimiliano.culpo@googlemail.com>2016-04-07 10:48:16 +0200
committeralalazo <massimiliano.culpo@googlemail.com>2016-04-07 10:48:16 +0200
commit1714f410f056db92a6aa42e4cc0505e79e8817a4 (patch)
tree7763f65d43f3472d39b1ad486e97ecb2cbd42e64 /lib
parent7dc1524c0807ea8cb6cf990d1811e0ca2218444a (diff)
parente73caad0d76fe8710ae054f4bcdbad1a649dbb92 (diff)
downloadspack-1714f410f056db92a6aa42e4cc0505e79e8817a4.tar.gz
spack-1714f410f056db92a6aa42e4cc0505e79e8817a4.tar.bz2
spack-1714f410f056db92a6aa42e4cc0505e79e8817a4.tar.xz
spack-1714f410f056db92a6aa42e4cc0505e79e8817a4.zip
Merge branch 'develop' of https://github.com/LLNL/spack into features/custom_modulefile_from_config
Diffstat (limited to 'lib')
-rwxr-xr-xlib/spack/env/cc94
-rw-r--r--lib/spack/spack/cmd/module.py10
-rw-r--r--lib/spack/spack/modules.py6
-rw-r--r--lib/spack/spack/test/mock_database.py4
4 files changed, 57 insertions, 57 deletions
diff --git a/lib/spack/env/cc b/lib/spack/env/cc
index 2eb6f46afe..18fd8f7bdb 100755
--- a/lib/spack/env/cc
+++ b/lib/spack/env/cc
@@ -39,7 +39,7 @@
#
# 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
+# the script runs. They are set by routines in spack.build_environment
# as part of spack.package.Package.do_install().
parameters="
SPACK_PREFIX
@@ -50,7 +50,7 @@ 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:
+# 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
@@ -66,11 +66,10 @@ function die {
for param in $parameters; do
if [[ -z ${!param} ]]; then
- die "Spack compiler must be run from spack! Input $param was missing!"
+ die "Spack compiler must be run from Spack! Input '$param' is missing."
fi
done
-#
# Figure out the type of compiler, the language, and the mode so that
# the compiler script knows what to do.
#
@@ -78,19 +77,18 @@ done
# 'command' is set based on the input command to $SPACK_[CC|CXX|F77|F90]
#
# 'mode' is set to one of:
+# vcheck version check
# cpp preprocess
# cc compile
# as assemble
# ld link
# ccld compile & link
-# vcheck version check
-#
-# Depending on the mode, we may or may not add extra rpaths.
-# This variable controls whether they are added.
-add_rpaths=true
command=$(basename "$0")
case "$command" in
+ cpp)
+ mode=cpp
+ ;;
cc|c89|c99|gcc|clang|icc|pgcc|xlc)
command="$SPACK_CC"
language="C"
@@ -107,34 +105,20 @@ case "$command" in
command="$SPACK_F77"
language="Fortran 77"
;;
- cpp)
- mode=cpp
- ;;
ld)
mode=ld
-
- # Darwin's linker has a -r argument that merges object files
- # together. It doesn't work with -rpath.
- if [[ $OSTYPE = darwin* ]]; then
- for arg in "$@"; do
- if [ "$arg" = -r ]; then
- add_rpaths=false
- break
- fi
- done
- fi
;;
*)
die "Unkown compiler: $command"
;;
esac
-# 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
-if [ -z "$mode" ]; then
+# If any of the arguments below are present, then the mode is vcheck.
+# In vcheck mode, nothing is added in terms of extra search paths or
+# libraries.
+if [[ -z $mode ]]; then
for arg in "$@"; do
- if [ "$arg" = -v -o "$arg" = -V -o "$arg" = --version -o "$arg" = -dumpversion ]; then
+ if [[ $arg == -v || $arg == -V || $arg == --version || $arg == -dumpversion ]]; then
mode=vcheck
break
fi
@@ -142,16 +126,16 @@ if [ -z "$mode" ]; then
fi
# Finish setting up the mode.
-if [ -z "$mode" ]; then
+if [[ -z $mode ]]; then
mode=ccld
for arg in "$@"; do
- if [ "$arg" = -E ]; then
+ if [[ $arg == -E ]]; then
mode=cpp
break
- elif [ "$arg" = -S ]; then
+ elif [[ $arg == -S ]]; then
mode=as
break
- elif [ "$arg" = -c ]; then
+ elif [[ $arg == -c ]]; then
mode=cc
break
fi
@@ -159,7 +143,7 @@ if [ -z "$mode" ]; then
fi
# Dump the version and exit if we're in testing mode.
-if [ "$SPACK_TEST_COMMAND" = "dump-mode" ]; then
+if [[ $SPACK_TEST_COMMAND == dump-mode ]]; then
echo "$mode"
exit
fi
@@ -170,10 +154,23 @@ if [[ -z $command ]]; then
die "ERROR: Compiler '$SPACK_COMPILER_SPEC' does not support compiling $language programs."
fi
-if [ "$mode" == vcheck ] ; then
+if [[ $mode == vcheck ]]; then
exec ${command} "$@"
fi
+# Darwin's linker has a -r argument that merges object files together.
+# It doesn't work with -rpath.
+# This variable controls whether they are added.
+add_rpaths=true
+if [[ mode == ld && $OSTYPE == darwin* ]]; then
+ for arg in "$@"; do
+ if [[ $arg == -r ]]; then
+ add_rpaths=false
+ break
+ fi
+ done
+fi
+
# Save original command for debug logging
input_command="$@"
args=("$@")
@@ -183,17 +180,17 @@ IFS=':' read -ra deps <<< "$SPACK_DEPENDENCIES"
for dep in "${deps[@]}"; do
# Prepend include directories
if [[ -d $dep/include ]]; then
- if [[ $mode = cpp || $mode = cc || $mode = as || $mode = ccld ]]; then
+ if [[ $mode == cpp || $mode == cc || $mode == as || $mode == ccld ]]; then
args=("-I$dep/include" "${args[@]}")
fi
fi
# Prepend lib and RPATH directories
if [[ -d $dep/lib ]]; then
- if [[ $mode = ccld ]]; then
+ if [[ $mode == ccld ]]; then
$add_rpaths && args=("-Wl,-rpath,$dep/lib" "${args[@]}")
args=("-L$dep/lib" "${args[@]}")
- elif [[ $mode = ld ]]; then
+ elif [[ $mode == ld ]]; then
$add_rpaths && args=("-rpath" "$dep/lib" "${args[@]}")
args=("-L$dep/lib" "${args[@]}")
fi
@@ -201,10 +198,10 @@ for dep in "${deps[@]}"; do
# Prepend lib64 and RPATH directories
if [[ -d $dep/lib64 ]]; then
- if [[ $mode = ccld ]]; then
+ if [[ $mode == ccld ]]; then
$add_rpaths && args=("-Wl,-rpath,$dep/lib64" "${args[@]}")
args=("-L$dep/lib64" "${args[@]}")
- elif [[ $mode = ld ]]; then
+ elif [[ $mode == ld ]]; then
$add_rpaths && args=("-rpath" "$dep/lib64" "${args[@]}")
args=("-L$dep/lib64" "${args[@]}")
fi
@@ -212,9 +209,9 @@ for dep in "${deps[@]}"; do
done
# Include all -L's and prefix/whatever dirs in rpath
-if [[ $mode = ccld ]]; then
+if [[ $mode == ccld ]]; then
$add_rpaths && args=("-Wl,-rpath,$SPACK_PREFIX/lib" "-Wl,-rpath,$SPACK_PREFIX/lib64" "${args[@]}")
-elif [[ $mode = ld ]]; then
+elif [[ $mode == ld ]]; then
$add_rpaths && args=("-rpath" "$SPACK_PREFIX/lib" "-rpath" "$SPACK_PREFIX/lib64" "${args[@]}")
fi
@@ -234,11 +231,14 @@ IFS=':' read -ra spack_env_dirs <<< "$SPACK_ENV_PATH"
spack_env_dirs+=("" ".")
PATH=""
for dir in "${env_path[@]}"; do
- remove=""
- for rm_dir in "${spack_env_dirs[@]}"; do
- if [[ $dir = $rm_dir ]]; then remove=True; fi
+ addpath=true
+ for env_dir in "${spack_env_dirs[@]}"; do
+ if [[ $dir == $env_dir ]]; then
+ addpath=false
+ break
+ fi
done
- if [[ -z $remove ]]; then
+ if $addpath; then
PATH="${PATH:+$PATH:}$dir"
fi
done
@@ -247,7 +247,7 @@ export PATH
full_command=("$command" "${args[@]}")
# In test command mode, write out full command for Spack tests.
-if [[ $SPACK_TEST_COMMAND = dump-args ]]; then
+if [[ $SPACK_TEST_COMMAND == dump-args ]]; then
echo "${full_command[@]}"
exit
elif [[ -n $SPACK_TEST_COMMAND ]]; then
@@ -257,7 +257,7 @@ fi
#
# Write the input and output commands to debug logs if it's asked for.
#
-if [[ $SPACK_DEBUG = TRUE ]]; then
+if [[ $SPACK_DEBUG == TRUE ]]; then
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"
echo "[$mode] $command $input_command" >> $input_log
diff --git a/lib/spack/spack/cmd/module.py b/lib/spack/spack/cmd/module.py
index 315d9fc926..a67f5c0c13 100644
--- a/lib/spack/spack/cmd/module.py
+++ b/lib/spack/spack/cmd/module.py
@@ -22,21 +22,16 @@
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
-import sys
import os
import shutil
-import argparse
+import sys
import llnl.util.tty as tty
-from llnl.util.lang import partition_list
-from llnl.util.filesystem import mkdirp
-
import spack.cmd
+from llnl.util.filesystem import mkdirp
from spack.modules import module_types
from spack.util.string import *
-from spack.spec import Spec
-
description ="Manipulate modules and dotkits."
@@ -98,7 +93,6 @@ def module_refresh():
cls(spec).write()
-
def module(parser, args):
if args.module_command == 'refresh':
module_refresh()
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index 4f7f67e910..747c0d3be5 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -311,7 +311,11 @@ class EnvModule(object):
def remove(self):
mod_file = self.file_name
if os.path.exists(mod_file):
- shutil.rmtree(mod_file, ignore_errors=True)
+ try:
+ os.remove(mod_file) # Remove the module file
+ os.removedirs(os.path.dirname(mod_file)) # Remove all the empty directories from the leaf up
+ except OSError:
+ pass # removedirs throws OSError on first non-empty directory found
class Dotkit(EnvModule):
diff --git a/lib/spack/spack/test/mock_database.py b/lib/spack/spack/test/mock_database.py
index 6fd05439bf..82ba59fc48 100644
--- a/lib/spack/spack/test/mock_database.py
+++ b/lib/spack/spack/test/mock_database.py
@@ -17,7 +17,7 @@ class MockDatabase(MockPackagesTest):
def _mock_remove(self, spec):
specs = spack.installed_db.query(spec)
- assert(len(specs) == 1)
+ assert len(specs) == 1
spec = specs[0]
spec.package.do_uninstall(spec)
@@ -71,6 +71,8 @@ class MockDatabase(MockPackagesTest):
self._mock_install('mpileaks ^zmpi')
def tearDown(self):
+ for spec in spack.installed_db.query():
+ spec.package.do_uninstall(spec)
super(MockDatabase, self).tearDown()
shutil.rmtree(self.install_path)
spack.install_path = self.spack_install_path