summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-10-07 08:33:54 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2020-11-17 10:04:13 -0800
commit51af590e64f6045fb8e72195d4adcd8d50c984bb (patch)
tree08f485b0bbaecd6828a33d286f3c50656996e789
parentbe10568a6ac48aabf475840a45fbebd753ba2749 (diff)
downloadspack-51af590e64f6045fb8e72195d4adcd8d50c984bb.tar.gz
spack-51af590e64f6045fb8e72195d4adcd8d50c984bb.tar.bz2
spack-51af590e64f6045fb8e72195d4adcd8d50c984bb.tar.xz
spack-51af590e64f6045fb8e72195d4adcd8d50c984bb.zip
variants: allow MultiValuedVariants to be constructed incrementally
-rw-r--r--lib/spack/spack/solver/asp.py18
-rw-r--r--lib/spack/spack/variant.py5
2 files changed, 18 insertions, 5 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index fe72b777d6..74bdeb69a3 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -198,6 +198,11 @@ class AspGenerator(object):
v for v in self.possible_versions[spec.name]
if v.satisfies(spec.versions)
]
+
+ # don't bother restricting anything if all versions are allowed
+ if len(allowed_versions) == len(self.possible_versions[spec.name]):
+ return []
+
predicates = [fn.version(spec.name, v) for v in allowed_versions]
# conflict with any versions that do not satisfy the spec
@@ -288,9 +293,6 @@ class AspGenerator(object):
"""
clauses = []
- if spec.name:
- clauses.append(fn.node(spec.name))
-
clauses.extend(self.spec_versions(spec))
# seed architecture at the root (we'll propagate later)
@@ -428,8 +430,14 @@ class ResultParser(object):
def variant_value(self, pkg, name, value):
pkg_class = spack.repo.path.get_pkg_class(pkg)
- variant = pkg_class.variants[name].make_variant(value)
- self._specs[pkg].variants[name] = variant
+
+ variant = self._specs[pkg].variants.get(name)
+ if variant:
+ # it's multi-valued
+ variant.append(value)
+ else:
+ variant = pkg_class.variants[name].make_variant(value)
+ self._specs[pkg].variants[name] = variant
def version(self, pkg, version):
self._specs[pkg].versions = ver([version])
diff --git a/lib/spack/spack/variant.py b/lib/spack/spack/variant.py
index 280f2346dd..e50c34a07d 100644
--- a/lib/spack/spack/variant.py
+++ b/lib/spack/spack/variant.py
@@ -389,6 +389,11 @@ class MultiValuedVariant(AbstractVariant):
return super_sat and (all(v in self.value for v in other.value) or
'*' in other or '*' in self)
+ def append(self, value):
+ """Add another value to this multi-valued variant."""
+ self._value = tuple(sorted((value,) + self._value))
+ self._original_value = ",".join(self._value)
+
class SingleValuedVariant(AbstractVariant):
"""A variant that can hold multiple values, but one at a time."""