diff options
author | Massimiliano Culpo <massimiliano.culpo@gmail.com> | 2020-11-12 00:31:39 +0100 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2020-11-17 10:04:13 -0800 |
commit | ca31f52be332bbfb8e8d5248218a81d9123c4ba2 (patch) | |
tree | 81d05acb0376e7ff6440221ef4e03ad3a4aa6572 /lib | |
parent | 9a03fd2834b29920ee0c11060dc928f368863606 (diff) | |
download | spack-ca31f52be332bbfb8e8d5248218a81d9123c4ba2.tar.gz spack-ca31f52be332bbfb8e8d5248218a81d9123c4ba2.tar.bz2 spack-ca31f52be332bbfb8e8d5248218a81d9123c4ba2.tar.xz spack-ca31f52be332bbfb8e8d5248218a81d9123c4ba2.zip |
concretizer: maximize the number of default values used for a single variant
If a the default of a multi-valued variant is set to
multiple values either in package.py or in packages.yaml
we need to ensure that all the values are present in the
concretized spec.
Since each default value has a weight of 0 and the
variant value is set implicitly by the concretizer
we need to add a rule to maximize on the number of
default values that are used.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/solver/concretize.lp | 14 | ||||
-rw-r--r-- | lib/spack/spack/test/concretize_preferences.py | 3 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp index d6d6c835ca..baf1c5239f 100644 --- a/lib/spack/spack/solver/concretize.lp +++ b/lib/spack/spack/solver/concretize.lp @@ -504,6 +504,13 @@ root(Dependency, 1) :- not root(Dependency), node(Dependency). Weight@14,Package,Variant,Value : variant_not_default(Package, Variant, Value, Weight), root(Package) }. +% If the value is a multivalued variant there could be multiple +% values set as default. Since a default value has a weight of 0 we +% need to maximize their number below to ensure they're all set +#maximize { + 1@13,Package,Variant,Value + : variant_not_default(Package, Variant, Value, Weight), root(Package) +}. #minimize{ Weight@13,Provider : provider_weight(Provider, Weight), root(Provider) @@ -538,6 +545,13 @@ root(Dependency, 1) :- not root(Dependency), node(Dependency). Weight@9,Package,Variant,Value : variant_not_default(Package, Variant, Value, Weight), not root(Package) }. +% If the value is a multivalued variant there could be multiple +% values set as default. Since a default value has a weight of 0 we +% need to maximize their number below to ensure they're all set +#maximize { + 1@8,Package,Variant,Value + : variant_not_default(Package, Variant, Value, Weight), not root(Package) +}. #minimize{ Weight@8,Package : version_weight(Package, Weight) }. diff --git a/lib/spack/spack/test/concretize_preferences.py b/lib/spack/spack/test/concretize_preferences.py index c138632ffa..d13748ad8b 100644 --- a/lib/spack/spack/test/concretize_preferences.py +++ b/lib/spack/spack/test/concretize_preferences.py @@ -80,6 +80,9 @@ class TestConcretizePreferences(object): # Use different values for the variants and check them again ('mpileaks', ['+debug', '+opt', '~shared', '-static'], {'debug': True, 'opt': True, 'shared': False, 'static': False}), + # Check a multivalued variant with multiple values set + ('multivalue-variant', ['foo=bar,baz', 'fee=bar'], + {'foo': ('bar', 'baz'), 'fee': 'bar'}) ]) def test_preferred_variants( self, package_name, variant_value, expected_results |