summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGregory Becker <becker33@llnl.gov>2015-11-11 11:32:18 -0800
committerGregory Becker <becker33@llnl.gov>2015-11-11 11:32:18 -0800
commit95a34628a3bebe3d263afbd2707cb5d47a2b7a33 (patch)
treedf05288e13743e0c410dcd078fe58cf711470ee9 /lib
parent7e6fc79eb240e69ff821899294dc99699ceb1573 (diff)
downloadspack-95a34628a3bebe3d263afbd2707cb5d47a2b7a33.tar.gz
spack-95a34628a3bebe3d263afbd2707cb5d47a2b7a33.tar.bz2
spack-95a34628a3bebe3d263afbd2707cb5d47a2b7a33.tar.xz
spack-95a34628a3bebe3d263afbd2707cb5d47a2b7a33.zip
Add modules to compilers. Changed compiler to take paths as a list. Changed compiler_for_spec to be aware of different compiler stratigies
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/compiler.py61
-rw-r--r--lib/spack/spack/compilers/__init__.py13
-rw-r--r--lib/spack/spack/package.py2
3 files changed, 27 insertions, 49 deletions
diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py
index 67765dfb7b..4be573fb12 100644
--- a/lib/spack/spack/compiler.py
+++ b/lib/spack/spack/compiler.py
@@ -106,17 +106,20 @@ class Compiler(object):
PrgEnv_compiler = None
- def __init__(self, cspec, cc, cxx, f77, fc, modules=None):
+ def __init__(self, cspec, paths, modules=None):
def check(exe):
if exe is None:
return None
_verify_executables(exe)
return exe
- self.cc = check(cc)
- self.cxx = check(cxx)
- self.f77 = check(f77)
- self.fc = check(fc)
+ self.cc = check(paths[0])
+ self.cxx = check(paths[1])
+ self.f77 = check(paths[2])
+ if len(paths) == 3:
+ self.fc = self.f77
+ else:
+ self.fc = check(paths[3])
self.spec = cspec
self.modules = modules
@@ -264,7 +267,7 @@ class Compiler(object):
if newcount <= prevcount:
continue
- compilers[ver] = cls(spec, *paths)
+ compilers[ver] = cls(spec, paths)
return list(compilers.values())
@@ -277,60 +280,26 @@ class Compiler(object):
if not cls.PrgEnv_compiler:
tty.die('Must supply PrgEnv_compiler with PrgEnv')
-# output = _shell('module avail %s' % cls.PrgEnv_compiler)
modulecmd = which('modulecmd')
- modulecmd
+ modulecmd.add_default_arg('python')
+ output = modulecmd('avail', return_oe=True)
matches = re.findall(r'(%s)/([^\s(]*)' % cls.PrgEnv_compiler, output)
- loaded_modules = os.environ["LOADEDMODULES"].split(":")
+# loaded_modules = os.environ["LOADEDMODULES"].split(":")
#output = _shell('module avail %s' % cls.PrgEnv_compiler)
- for module in loaded_modules:
- match = re.findall(r'(%s)/([^\s(]*)' % cls.PrgEnv_compiler, module)
+# for module in loaded_modules:
+# match = re.findall(r'(%s)/([^\s(]*)' % cls.PrgEnv_compiler, module)
for name, version in matches:
v = version + '-craype'
comp = cls(spack.spec.CompilerSpec(name + '@' + v),
- 'cc', 'CC', 'ftn', 'ftn', name +'/' + v)
+ ['cc', 'CC', 'ftn'], [cls.PrgEnv, name +'/' + v])
compilers.append(comp)
return compilers
-def _cur_prgenv():
- out, err = subprocess.Popen(
- ['module list'], shell=True,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
- matches = re.findall(r'(PrgEnv-[^/]*)/', err)
- return matches[0]
-
-
-def _module_shell(module, *args):
- cmd = 'module swap %s %s;' % (_cur_prgenv(), module)
- cmd += 'module load %s;' % compiler
- cmd += 'module unload cray-libsci;'
-
-# +
-# 'module load craype-network-gemini;' +
-# 'module load %s;' % module +
-# 'module swap gcc/4.6.1;' +
-# 'module load eswrap; ' +
-# 'module load craype-mc12; ' +
-# 'module load cray-shmem; ' +
-# 'module load cray-mpich; ')
- cmd += ' '.join(args)
- out, err = subprocess.Popen([cmd + ' '.join(args)], shell=True,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
- return out
-
-
-def _shell(*args):
- return subprocess.Popen([' '.join(args)], shell=True,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[1]
-
-
-
-
def __repr__(self):
"""Return a string represntation of the compiler toolchain."""
return self.__str__()
diff --git a/lib/spack/spack/compilers/__init__.py b/lib/spack/spack/compilers/__init__.py
index 8c4cb38926..6fc54daa61 100644
--- a/lib/spack/spack/compilers/__init__.py
+++ b/lib/spack/spack/compilers/__init__.py
@@ -197,18 +197,27 @@ def compilers_for_spec(compiler_spec):
else:
compiler_paths.append(None)
- return cls(cspec, *compiler_paths)
+ for m in _optional_instance_vars:
+ if m not in items:
+ items[m] = None
+ mods = items[m]
+
+ return cls(cspec, compiler_paths, mods)
matches = find(compiler_spec)
return [get_compiler(cspec) for cspec in matches]
@_auto_compiler_spec
-def compiler_for_spec(compiler_spec):
+def compiler_for_spec(compiler_spec, target):
"""Get the compiler that satisfies compiler_spec. compiler_spec must
be concrete."""
assert(compiler_spec.concrete)
compilers = compilers_for_spec(compiler_spec)
+ if target.compiler_strategy == "PATH":
+ filter(lambda c: c.modules is None, compilers)
+ elif target.compiler_strategy == "MODULES":
+ filter(lambda c: c.modules is not None, compilers)
assert(len(compilers) == 1)
return compilers[0]
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index 61606d0590..b6a98f3ee6 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -592,7 +592,7 @@ class Package(object):
"""Get the spack.compiler.Compiler object used to build this package."""
if not self.spec.concrete:
raise ValueError("Can only get a compiler for a concrete package.")
- return spack.compilers.compiler_for_spec(self.spec.compiler)
+ return spack.compilers.compiler_for_spec(self.spec.compiler, self.spec.architecture)
def url_version(self, version):