summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGregory Becker <becker33@llnl.gov>2016-04-28 11:05:59 -0700
committerGregory Becker <becker33@llnl.gov>2016-04-28 11:05:59 -0700
commit3b84345b7721e9da1c816a492c0d449fd519a1f6 (patch)
tree862e2ef36cd150d3b6318f64f82922c933e95e36 /lib
parentae5198e5e765c64fea666753905f5162f2300181 (diff)
downloadspack-3b84345b7721e9da1c816a492c0d449fd519a1f6.tar.gz
spack-3b84345b7721e9da1c816a492c0d449fd519a1f6.tar.bz2
spack-3b84345b7721e9da1c816a492c0d449fd519a1f6.tar.xz
spack-3b84345b7721e9da1c816a492c0d449fd519a1f6.zip
Changed yaml format for node_dicts to mitigate future incompatibilities
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/spec.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 2bd5d85c57..7ab8102935 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -760,13 +760,13 @@ class Spec(object):
def to_node_dict(self):
+ params = dict( (name, v.value) for name, v in self.variants.items() )
+ params.update( dict( (name, value) for name, value in self.compiler_flags.items()) )
d = {
- 'variants' : dict(
- (name,v.value) for name, v in self.variants.items()),
+ 'parameters' : params,
'arch' : self.architecture,
'dependencies' : dict((d, self.dependencies[d].dag_hash())
for d in sorted(self.dependencies)),
- 'compiler_flags' : dict((name, value) for name, value in self.compiler_flags.items())
}
# Older concrete specs do not have a namespace. Omit for
@@ -807,11 +807,17 @@ class Spec(object):
else:
spec.compiler = CompilerSpec.from_dict(node)
- for name, value in node['variants'].items():
- spec.variants[name] = VariantSpec(name, value)
-
- for name, value in node['compiler_flags'].items():
- spec.compiler_flags[name] = value
+ if 'parameters' in node:
+ for name, value in node['parameters'].items():
+ if name in _valid_compiler_flags:
+ spec.compiler_flags[name] = value
+ else:
+ spec.variants[name] = VariantSpec(name, value)
+ elif 'variants' in node:
+ for name, value in node['variants'].items():
+ spec.variants[name] = VariantSpec(name, value)
+ else:
+ raise SpackRecordError("Did not find a valid format for variants in YAML file")
return spec
@@ -2436,3 +2442,7 @@ class UnsatisfiableDependencySpecError(UnsatisfiableSpecError):
class SpackYAMLError(spack.error.SpackError):
def __init__(self, msg, yaml_error):
super(SpackYAMLError, self).__init__(msg, str(yaml_error))
+
+class SpackRecordError(spack.error.SpackError):
+ def __init__(self, msg):
+ super(SpackRecordError, self).__init__(msg)