solver: clean up emission of conflicts

This commit is contained in:
Gregory Becker
2022-04-19 11:34:57 -07:00
parent d501ce0c7e
commit 3fa447a84a
2 changed files with 7 additions and 5 deletions

View File

@@ -747,13 +747,15 @@ def target_ranges(self, spec, single_target_fn):
return [fn.node_target_satisfies(spec.name, target)]
def conflict_rules(self, pkg):
default_msg = "{0} conflicts for '{1}' and '{2}'"
for trigger, constraints in pkg.conflicts.items():
trigger_id = self.condition(spack.spec.Spec(trigger), name=pkg.name)
self.gen.fact(fn.conflict_trigger(trigger_id))
for constraint, _ in constraints:
for constraint, msg in constraints:
if msg is None:
msg = default_msg.format(pkg.name, trigger, constraint)
constraint_id = self.condition(constraint, name=pkg.name)
self.gen.fact(fn.conflict(pkg.name, trigger_id, constraint_id))
self.gen.fact(fn.conflict(pkg.name, trigger_id, constraint_id, msg))
self.gen.newline()
def available_compilers(self):

View File

@@ -180,13 +180,13 @@ path(Parent, Descendant) :- path(Parent, A), depends_on(A, Descendant).
% Conflicts
%-----------------------------------------------------------------------------
:- node(Package),
conflict(Package, TriggerID, ConstraintID),
conflict(Package, TriggerID, ConstraintID, Msg),
condition_holds(TriggerID),
condition_holds(ConstraintID),
not external(Package), % ignore conflicts for externals
error("A conflict was triggered").
#defined conflict/3.
#defined conflict/4.
%-----------------------------------------------------------------------------
% Virtual dependencies