variants: allow MultiValuedVariants to be constructed incrementally
This commit is contained in:
parent
be10568a6a
commit
51af590e64
2 changed files with 18 additions and 5 deletions
|
@ -198,6 +198,11 @@ def spec_versions(self, spec):
|
|||
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 @@ def spec_clauses(self, spec):
|
|||
"""
|
||||
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 @@ def arch_target(self, pkg, target):
|
|||
|
||||
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])
|
||||
|
|
|
@ -389,6 +389,11 @@ def satisfies(self, other):
|
|||
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."""
|
||||
|
|
Loading…
Reference in a new issue