bugfix: do not generate dep conditions when no dependency
We only consider test dependencies some of the time. Some packages are *only* test dependencies. Spack's algorithm was previously generating dependency conditions that could hold, *even* if there was no potential dependency type. - [x] change asp.py so that this can't happen -- we now only generate dependency types for possible dependencies.
This commit is contained in:
parent
ada6ecc797
commit
e7cba04b95
@ -683,21 +683,26 @@ def package_dependencies_rules(self, pkg, tests):
|
|||||||
"""Translate 'depends_on' directives into ASP logic."""
|
"""Translate 'depends_on' directives into ASP logic."""
|
||||||
for _, conditions in sorted(pkg.dependencies.items()):
|
for _, conditions in sorted(pkg.dependencies.items()):
|
||||||
for cond, dep in sorted(conditions.items()):
|
for cond, dep in sorted(conditions.items()):
|
||||||
|
deptypes = dep.type.copy()
|
||||||
|
# Skip test dependencies if they're not requested
|
||||||
|
if not tests:
|
||||||
|
deptypes.discard("test")
|
||||||
|
|
||||||
|
# ... or if they are requested only for certain packages
|
||||||
|
if not isinstance(tests, bool) and pkg.name not in tests:
|
||||||
|
deptypes.discard("test")
|
||||||
|
|
||||||
|
# if there are no dependency types to be considered
|
||||||
|
# anymore, don't generate the dependency
|
||||||
|
if not deptypes:
|
||||||
|
continue
|
||||||
|
|
||||||
condition_id = self.condition(cond, dep.spec, pkg.name)
|
condition_id = self.condition(cond, dep.spec, pkg.name)
|
||||||
self.gen.fact(fn.dependency_condition(
|
self.gen.fact(fn.dependency_condition(
|
||||||
condition_id, pkg.name, dep.spec.name
|
condition_id, pkg.name, dep.spec.name
|
||||||
))
|
))
|
||||||
|
|
||||||
for t in sorted(dep.type):
|
for t in sorted(deptypes):
|
||||||
# Skip test dependencies if they're not requested at all
|
|
||||||
if t == 'test' and not tests:
|
|
||||||
continue
|
|
||||||
|
|
||||||
# ... or if they are requested only for certain packages
|
|
||||||
if t == 'test' and (not isinstance(tests, bool)
|
|
||||||
and pkg.name not in tests):
|
|
||||||
continue
|
|
||||||
|
|
||||||
# there is a declared dependency of type t
|
# there is a declared dependency of type t
|
||||||
self.gen.fact(fn.dependency_type(condition_id, t))
|
self.gen.fact(fn.dependency_type(condition_id, t))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user