concretizer: initial support for virtual dependencies
Add initial support for virtual dependencies. Solver now knows about all virtuals and can choose one to resolve a dependency.
This commit is contained in:
parent
3f93553a08
commit
be10568a6a
@ -278,7 +278,7 @@ def pkg_rules(self, pkg):
|
||||
# dependencies
|
||||
for name, conditions in pkg.dependencies.items():
|
||||
for cond, dep in conditions.items():
|
||||
self.fact(fn.depends_on(dep.pkg.name, dep.spec.name))
|
||||
self.fact(fn.declared_dependency(dep.pkg.name, dep.spec.name))
|
||||
|
||||
def spec_clauses(self, spec):
|
||||
"""Return a list of clauses the spec mandates are true.
|
||||
@ -347,9 +347,11 @@ def arch_defaults(self):
|
||||
self.fact(fn.arch_target_default(default_arch.target))
|
||||
|
||||
def virtual_providers(self, virtuals):
|
||||
self.h2("Virtual providers")
|
||||
for vspec in virtuals:
|
||||
providers = spack.repo.path.providers_for(vspec)
|
||||
print("PROVIDE", providers, [type(t) for t in providers])
|
||||
self.fact(fn.virtual(vspec))
|
||||
for provider in spack.repo.path.providers_for(vspec):
|
||||
self.fact(fn.provides_virtual(provider, vspec))
|
||||
|
||||
def generate_asp_program(self, specs):
|
||||
"""Write an ASP program for specs.
|
||||
@ -363,9 +365,10 @@ def generate_asp_program(self, specs):
|
||||
pkg_names = set(spec.fullname for spec in specs)
|
||||
|
||||
possible = set()
|
||||
virtuals = set()
|
||||
for name in pkg_names:
|
||||
pkg = spack.repo.path.get_pkg_class(name)
|
||||
possible.update(pkg.possible_dependencies())
|
||||
possible.update(pkg.possible_dependencies(virtuals=virtuals))
|
||||
|
||||
pkgs = set(possible) | set(pkg_names)
|
||||
|
||||
|
@ -17,12 +17,21 @@ version_possible(P, V) :- version_declared(P, V), not version_conflict(P, V).
|
||||
%-----------------------------------------------------------------------------
|
||||
% Dependency semantics
|
||||
%-----------------------------------------------------------------------------
|
||||
% declared dependencies are real if they're not virtual
|
||||
depends_on(P, D) :- declared_dependency(P, D), not virtual(D), node(P).
|
||||
|
||||
% dependencies imply new nodes.
|
||||
% if you declare a dependency on a virtual, you depend on one of its providers
|
||||
1 { depends_on(P, Q) : provides_virtual(Q, V) } 1
|
||||
:- declared_dependency(P, V), virtual(V), node(P).
|
||||
|
||||
% real dependencies imply new nodes.
|
||||
node(D) :- node(P), depends_on(P, D).
|
||||
|
||||
% do not warn for solves with no dependencies
|
||||
% do not warn if generated program contains none of these.
|
||||
#defined depends_on/2.
|
||||
#defined declared_dependency/2.
|
||||
#defined virtual/1.
|
||||
#defined provides_virtual/2.
|
||||
|
||||
%-----------------------------------------------------------------------------
|
||||
% Variant semantics
|
||||
|
Loading…
Reference in New Issue
Block a user