summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/spec.py21
1 files changed, 13 insertions, 8 deletions
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index 3bee81c0d4..4b6bd67b6d 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -1117,6 +1117,18 @@ class Spec(object):
self._dependencies[spec.name] = dspec
spec._dependents[self.name] = dspec
+ def _add_default_platform(self):
+ """If a spec has an os or a target and no platform, give it
+ the default platform.
+
+ This is private because it is used by the parser -- it's not
+ expected to be used outside of ``spec.py``.
+
+ """
+ arch = self.architecture
+ if arch and not arch.platform and (arch.os or arch.target):
+ self._set_architecture(platform=spack.architecture.platform().name)
+
#
# Public interface
#
@@ -4053,14 +4065,6 @@ class SpecParser(spack.parse.Parser):
except spack.parse.ParseError as e:
raise SpecParseError(e)
- # If the spec has an os or a target and no platform, give it
- # the default platform
- platform_default = spack.architecture.platform().name
- for spec in specs:
- for s in spec.traverse():
- if s.architecture and not s.architecture.platform and \
- (s.architecture.os or s.architecture.target):
- s._set_architecture(platform=platform_default)
return specs
def spec_from_file(self):
@@ -4192,6 +4196,7 @@ class SpecParser(spack.parse.Parser):
else:
break
+ spec._add_default_platform()
return spec
def variant(self, name=None):