summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/solver/asp.py11
-rw-r--r--lib/spack/spack/solver/concretize.lp13
2 files changed, 18 insertions, 6 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index b102863446..fe72b777d6 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -278,7 +278,7 @@ class AspGenerator(object):
# 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 @@ class AspGenerator(object):
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 @@ class AspGenerator(object):
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)
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp
index dc7c28f7c3..19ae3a2417 100644
--- a/lib/spack/spack/solver/concretize.lp
+++ b/lib/spack/spack/solver/concretize.lp
@@ -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