solver: remove indirection for provider conditions

This commit is contained in:
Gregory Becker 2022-12-12 11:15:49 -08:00
parent ed76966a3a
commit acde8ef104
2 changed files with 5 additions and 15 deletions

View File

@ -1266,7 +1266,9 @@ def package_provider_rules(self, pkg):
for when in whens: for when in whens:
msg = "%s provides %s when %s" % (pkg.name, provided, when) msg = "%s provides %s when %s" % (pkg.name, provided, when)
condition_id = self.condition(when, provided, pkg.name, msg) condition_id = self.condition(when, provided, pkg.name, msg)
self.gen.fact(fn.provider_condition(condition_id, when.name, provided.name)) self.gen.fact(fn.imposed_constraint(
condition_id, "virtual_condition_holds", pkg.name, provided.name
))
self.gen.newline() self.gen.newline()
def package_dependencies_rules(self, pkg): def package_dependencies_rules(self, pkg):

View File

@ -330,17 +330,11 @@ attr("root", Package) :- attr("virtual_root", Virtual), provider(Package, Virtua
% for environments that are concretized together (e.g. where we % for environments that are concretized together (e.g. where we
% asks to install "mpich" and "hdf5+mpi" and we want "mpich" to % asks to install "mpich" and "hdf5+mpi" and we want "mpich" to
% be the mpi provider) % be the mpi provider)
provider(Package, Virtual) :- attr("node", Package), virtual_condition_holds(Package, Virtual). provider(Package, Virtual) :- attr("node", Package), attr("virtual_condition_holds", Package, Virtual).
% The provider provides the virtual if some provider condition holds.
virtual_condition_holds(Provider, Virtual) :-
provider_condition(ID, Provider, Virtual),
condition_holds(ID),
virtual(Virtual).
% A package cannot be the actual provider for a virtual if it does not % A package cannot be the actual provider for a virtual if it does not
% fulfill the conditions to provide that virtual % fulfill the conditions to provide that virtual
:- provider(Package, Virtual), not virtual_condition_holds(Package, Virtual), :- provider(Package, Virtual), not attr("virtual_condition_holds", Package, Virtual),
internal_error("Virtual when provides not respected"). internal_error("Virtual when provides not respected").
#defined possible_provider/2. #defined possible_provider/2.
@ -382,14 +376,8 @@ possible_provider_weight(Dependency, Virtual, 100, "fallback") :- provider(Depen
% do not warn if generated program contains none of these. % do not warn if generated program contains none of these.
#defined possible_provider/2. #defined possible_provider/2.
#defined provider_condition/3.
#defined required_provider_condition/3.
#defined required_provider_condition/4.
#defined required_provider_condition/5.
#defined required_provider_condition/6.
#defined declared_dependency/3. #defined declared_dependency/3.
#defined virtual/1. #defined virtual/1.
#defined virtual_condition_holds/2.
#defined external/1. #defined external/1.
#defined external_spec/2. #defined external_spec/2.
#defined external_version_declared/4. #defined external_version_declared/4.