concretizer: require only one provider for any virtual in the DAG

This commit is contained in:
Todd Gamblin 2019-10-09 12:02:56 -07:00
parent 501cb371c9
commit a332981f2f
2 changed files with 8 additions and 4 deletions

View File

@ -366,10 +366,7 @@ class Body(object):
clauses.append(f.node_compiler_version( clauses.append(f.node_compiler_version(
spec.name, spec.compiler.name, spec.compiler.version)) spec.name, spec.compiler.name, spec.compiler.version))
# if spec.dependencies:
# TODO # TODO
# dependencies
# external_path # external_path
# external_module # external_module
# compiler_flags # compiler_flags
@ -404,7 +401,8 @@ def virtual_providers(self, virtuals):
for vspec in virtuals: for vspec in virtuals:
self.fact(fn.virtual(vspec)) self.fact(fn.virtual(vspec))
for provider in spack.repo.path.providers_for(vspec): for provider in spack.repo.path.providers_for(vspec):
self.fact(fn.provides_virtual(provider, vspec)) # TODO: handle versioned virtuals
self.fact(fn.provides_virtual(provider.name, vspec))
def generate_asp_program(self, specs): def generate_asp_program(self, specs):
"""Write an ASP program for specs. """Write an ASP program for specs.

View File

@ -24,6 +24,12 @@ depends_on(P, D) :- declared_dependency(P, D), not virtual(D), node(P).
1 { depends_on(P, Q) : provides_virtual(Q, V) } 1 1 { depends_on(P, Q) : provides_virtual(Q, V) } 1
:- declared_dependency(P, V), virtual(V), node(P). :- declared_dependency(P, V), virtual(V), node(P).
% for any virtual, there can only be one node providing it in the DAG
provider(P, V) :- node(P), provides_virtual(P, V).
1 { provider(P, V) : node(P) } 1 :- virtual(V).
% all nodes must be reachable from some root
% TODO: this doesn't seem to be working yet
needed(D) :- depends_on(_, D), node(D). needed(D) :- depends_on(_, D), node(D).
needed(P) :- root(P). needed(P) :- root(P).
:- node(P), not needed(P). :- node(P), not needed(P).