diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2019-10-17 00:01:44 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2020-11-17 10:04:13 -0800 |
commit | db62b00d5891cb3e5d02123a5ef1089de9351991 (patch) | |
tree | eaae7b413dc779ba64904739bb51278066eb3873 /lib | |
parent | cde10692b0b12f859098cb8abe5450e72ea1a040 (diff) | |
download | spack-db62b00d5891cb3e5d02123a5ef1089de9351991.tar.gz spack-db62b00d5891cb3e5d02123a5ef1089de9351991.tar.bz2 spack-db62b00d5891cb3e5d02123a5ef1089de9351991.tar.xz spack-db62b00d5891cb3e5d02123a5ef1089de9351991.zip |
concretizer: handle dependency types
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/solve.py | 5 | ||||
-rw-r--r-- | lib/spack/spack/solver/asp.py | 34 | ||||
-rw-r--r-- | lib/spack/spack/solver/concretize.lp | 13 | ||||
-rw-r--r-- | lib/spack/spack/solver/display.lp | 2 | ||||
-rw-r--r-- | lib/spack/spack/spec.py | 5 |
5 files changed, 42 insertions, 17 deletions
diff --git a/lib/spack/spack/cmd/solve.py b/lib/spack/spack/cmd/solve.py index 7d26fb36bc..0cd11f5507 100644 --- a/lib/spack/spack/cmd/solve.py +++ b/lib/spack/spack/cmd/solve.py @@ -101,8 +101,9 @@ def solve(parser, args): assert best[1] == result.answers[-1][1] opt, i, answer = best - tty.msg("Best of %d answers." % (i + 1)) - tty.msg("Optimization %s" % opt) + if not args.yaml: + tty.msg("Best of %d answers." % (i + 1)) + tty.msg("Optimization %s" % opt) # iterate over roots from command line for spec in specs: diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py index 85b42453a4..080a685584 100644 --- a/lib/spack/spack/solver/asp.py +++ b/lib/spack/spack/solver/asp.py @@ -19,6 +19,7 @@ import llnl.util.tty.color as color import spack import spack.cmd import spack.config +import spack.dependency import spack.spec import spack.package import spack.package_prefs @@ -345,17 +346,26 @@ class AspGenerator(object): # dependencies for name, conditions in pkg.dependencies.items(): for cond, dep in conditions.items(): - decl = fn.declared_dependency(dep.pkg.name, dep.spec.name) if cond == spack.spec.Spec(): - self.fact(decl) + for t in dep.type: + self.fact( + fn.declared_dependency( + dep.pkg.name, dep.spec.name, t + ) + ) else: named_cond = cond.copy() if not named_cond.name: named_cond.name = pkg.name - self.rule( - decl, - self._and(*self.spec_clauses(named_cond, body=True)) - ) + for t in dep.type: + self.rule( + fn.declared_dependency( + dep.pkg.name, dep.spec.name, t + ), + self._and( + *self.spec_clauses(named_cond, body=True) + ) + ) # virtual preferences self.virtual_preferences( @@ -586,9 +596,13 @@ class ResultParser(object): self._specs[pkg].compiler.versions = spack.version.VersionList( [version]) - def depends_on(self, pkg, dep): - self._specs[pkg]._add_dependency( - self._specs[dep], ('link', 'run')) + def depends_on(self, pkg, dep, type): + dependency = self._specs[pkg]._dependencies.get(dep) + if not dependency: + self._specs[pkg]._add_dependency( + self._specs[dep], (type,)) + else: + dependency.add_type(type) def call_actions_for_functions(self, function_strings): function_re = re.compile(r'(\w+)\(([^)]*)\)') @@ -665,6 +679,8 @@ class ResultParser(object): costs = re.split(r"\s+", next(output).strip()) opt = [int(x) for x in costs[1:]] + for spec in self._specs.values(): + spec._mark_concrete() result.answers.append((opt, best_model_number, self._specs)) diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp index 3b58cb4e80..97ed4ea82e 100644 --- a/lib/spack/spack/solver/concretize.lp +++ b/lib/spack/spack/solver/concretize.lp @@ -24,12 +24,15 @@ version_weight(P, V, N) :- version(P, V), version_declared(P, V, N). %----------------------------------------------------------------------------- % Dependency semantics %----------------------------------------------------------------------------- +% Dependencies of any type imply that one package "depends on" another +depends_on(P, D) :- depends_on(P, D, _). + % declared dependencies are real if they're not virtual -depends_on(P, D) :- declared_dependency(P, D), not virtual(D), node(P). +depends_on(P, D, T) :- declared_dependency(P, D, T), not virtual(D), node(P). % 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). +1 { depends_on(P, Q, T) : provides_virtual(Q, V) } 1 + :- declared_dependency(P, V, T), 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). @@ -64,8 +67,8 @@ needed(D) :- needed(P), depends_on(P, D), node(P). node(D) :- node(P), depends_on(P, D). % do not warn if generated program contains none of these. -#defined depends_on/2. -#defined declared_dependency/2. +#defined depends_on/3. +#defined declared_dependency/3. #defined virtual/1. #defined provides_virtual/2. #defined pkg_provider_preference/4. diff --git a/lib/spack/spack/solver/display.lp b/lib/spack/spack/solver/display.lp index 4c94720fc7..e5be23b55c 100644 --- a/lib/spack/spack/solver/display.lp +++ b/lib/spack/spack/solver/display.lp @@ -4,7 +4,7 @@ % This section determines what parts of the model are printed at the end %============================================================================== #show node/1. -#show depends_on/2. +#show depends_on/3. #show version/2. #show variant_value/3. #show arch_platform/2. diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 9a13a7db46..e886108df1 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -622,6 +622,11 @@ class DependencySpec(object): def copy(self): return DependencySpec(self.parent, self.spec, self.deptypes) + def add_type(self, type): + self.deptypes = dp.canonical_deptype( + self.deptypes + dp.canonical_deptype(type) + ) + def _cmp_key(self): return (self.parent.name if self.parent else None, self.spec.name if self.spec else None, |