concretizer: simplify and suppress warnings for variant handling
We are relying on default logic in the variant handling in that we set a default value if we never see `variant_set(P, V, X)`. - Move the logic for this into `concretize.lp` instead of generating it for every package. - For programs that don't have explicit variant settings, clingo warns that variant_set(P, V, X) doesn't appear in any rule head, because a setting is never generated. - Specifically suppress this warning.
This commit is contained in:
parent
b171ac5050
commit
d94d957536
@ -196,14 +196,17 @@ def pkg_rules(self, pkg):
|
|||||||
single = fn.variant_single_value(pkg.name, name)
|
single = fn.variant_single_value(pkg.name, name)
|
||||||
if single_value:
|
if single_value:
|
||||||
self.rule(single, fn.node(pkg.name))
|
self.rule(single, fn.node(pkg.name))
|
||||||
self.rule(fn.variant_value(pkg.name, name, variant.default),
|
self.rule(
|
||||||
self._not(fn.variant_set(pkg.name, name)))
|
fn.variant_default_value(pkg.name, name, variant.default),
|
||||||
|
fn.node(pkg.name))
|
||||||
else:
|
else:
|
||||||
self.rule(self._not(single), fn.node(pkg.name))
|
self.rule(self._not(single), fn.node(pkg.name))
|
||||||
defaults = variant.default.split(',')
|
defaults = variant.default.split(',')
|
||||||
for val in defaults:
|
for val in defaults:
|
||||||
self.rule(fn.variant_value(pkg.name, name, val),
|
self.rule(
|
||||||
self._not(fn.variant_set(pkg.name, name)))
|
fn.variant_default_value(pkg.name, name, val),
|
||||||
|
fn.node(pkg.name))
|
||||||
|
self.out.write('\n')
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
for name, conditions in pkg.dependencies.items():
|
for name, conditions in pkg.dependencies.items():
|
||||||
@ -231,7 +234,7 @@ def spec_rules(self, spec):
|
|||||||
|
|
||||||
# variants
|
# variants
|
||||||
for vname, variant in spec.variants.items():
|
for vname, variant in spec.variants.items():
|
||||||
self.fact(fn.variant_value(spec.name, vname, variant.value))
|
self.fact(fn.variant_set(spec.name, vname, variant.value))
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
# dependencies
|
# dependencies
|
||||||
@ -265,9 +268,10 @@ def generate_asp_program(self, specs):
|
|||||||
|
|
||||||
self.title('Spec Constraints')
|
self.title('Spec Constraints')
|
||||||
for spec in specs:
|
for spec in specs:
|
||||||
self.section('Spec: %s' % pkg)
|
for dep in spec.traverse():
|
||||||
self.spec_rules(spec)
|
self.section('Spec: %s' % str(dep))
|
||||||
self.out.write('\n')
|
self.spec_rules(dep)
|
||||||
|
self.out.write('\n')
|
||||||
|
|
||||||
self.out.write(pkgutil.get_data('spack.solver', 'display.lp'))
|
self.out.write(pkgutil.get_data('spack.solver', 'display.lp'))
|
||||||
self.out.write('\n')
|
self.out.write('\n')
|
||||||
|
@ -25,6 +25,13 @@ arch_target(D, A) :- node(D), depends_on(P, D), arch_target(P, A).
|
|||||||
% if a variant is set to anything, it is considered 'set'.
|
% if a variant is set to anything, it is considered 'set'.
|
||||||
variant_set(P, V) :- variant_set(P, V, _).
|
variant_set(P, V) :- variant_set(P, V, _).
|
||||||
|
|
||||||
|
% suppress wranings about this atom being unset. It's only set if some
|
||||||
|
% spec or some package sets it, and without this, clingo will give
|
||||||
|
% warnings like 'info: atom does not occur in any rule head'.
|
||||||
|
#defined variant_set/3.
|
||||||
|
|
||||||
% variant_set is an explicitly set variant value. If it's not 'set',
|
% variant_set is an explicitly set variant value. If it's not 'set',
|
||||||
% we revert to the default value. If it is set, we force the set value
|
% we revert to the default value. If it is set, we force the set value
|
||||||
variant_value(P, V, X) :- node(P), variant(P, V), variant_set(P, V, X).
|
variant_value(P, V, X) :- node(P), variant(P, V), variant_set(P, V, X).
|
||||||
|
variant_value(P, V, X) :- node(P), variant(P, V), not variant_set(P, V),
|
||||||
|
variant_default_value(P, V, X).
|
||||||
|
Loading…
Reference in New Issue
Block a user