summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2014-05-01 22:51:36 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2014-06-22 12:33:49 -0700
commit1fa20ec2ba404912bd69c628f75f7ae4387d2fad (patch)
tree0a19db3f8d8ddb639f1ad746e425752436a9eac0 /lib
parentc66a6a16f9224ee340ba3f602115dc638f5807c4 (diff)
downloadspack-1fa20ec2ba404912bd69c628f75f7ae4387d2fad.tar.gz
spack-1fa20ec2ba404912bd69c628f75f7ae4387d2fad.tar.bz2
spack-1fa20ec2ba404912bd69c628f75f7ae4387d2fad.tar.xz
spack-1fa20ec2ba404912bd69c628f75f7ae4387d2fad.zip
partial checkin
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/compiler.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/lib/spack/spack/compiler.py b/lib/spack/spack/compiler.py
new file mode 100644
index 0000000000..f2df6a696d
--- /dev/null
+++ b/lib/spack/spack/compiler.py
@@ -0,0 +1,57 @@
+import os
+
+import spack.error
+from spack.version import Version
+from spack.util import Executable
+
+from subprocess import check_output
+
+
+def _verify_compiler(*paths):
+ for path in paths:
+ if not os.path.isfile(path) and os.access(path, os.X_OK):
+ raise InvalidCompilerPathError(path)
+
+
+class Compiler(object):
+ """This class encapsulates a Spack "compiler", which includes C,
+ C++, Fortran, and F90 compilers. Subclasses should implement
+ support for specific compilers, their possible names, arguments,
+ and how to identify the particular type of compiler."""
+
+ # Subclasses use possible names of C compiler
+ cc_names = []
+
+ # Subclasses use possible names of C++ compiler
+ cxx_names = []
+
+ # Subclasses use possible names of Fortran 77 compiler
+ f77_names = []
+
+ # Subclasses use possible names of Fortran 90 compiler
+ f90_names = []
+
+ # Names of generic arguments used by this compiler
+ arg_version = '-dumpversion'
+ arg_rpath = '-Wl,-rpath,%s'
+
+
+ def __init__(self, cc, cxx, f77, f90):
+ _verify_compiler(cc, cxx, f77, f90)
+ self.cc = Executable(cc)
+ self.cxx = Executable(cxx)
+ self.f77 = Executable(f77)
+ self.f90 = Executable(f90)
+
+
+ @property
+ @memoized
+ def version(self):
+ v = self.cc(arg_version)
+ return Version(v)
+
+
+class InvalidCompilerPathError(spack.error.SpackError):
+ def __init__(self, path):
+ super(InvalidCompilerPathError, self).__init__(
+ "'%s' is not a valid compiler." % path)