concretizer: add error messages and simplify asp.py

This commit is contained in:
Todd Gamblin 2021-11-04 17:20:43 -07:00
parent 0186f0f955
commit ac1e05fe1b
2 changed files with 18 additions and 8 deletions

View File

@ -1302,11 +1302,13 @@ def os_defaults(self, specs):
platform = spack.platforms.host()
# create set of OS's to consider
buildable = set([
platform.front_os, platform.back_os, platform.default_os])
buildable = set(platform.operating_sys.keys())
# Consider any OS's mentioned on the command line. We need this to
# cross-concretize in CI, and for some tests.
# TODO: OS should really be more than just a label -- rework this.
for spec in specs:
if spec.architecture and spec.architecture.os:
# TODO: does this make sense?
buildable.add(spec.architecture.os)
# make directives for buildable OS's
@ -1585,7 +1587,8 @@ def _facts_from_concrete_spec(self, spec, possible):
self.gen.newline()
# add OS to possible OS's
self.possible_oses.add(spec.os)
for dep in spec.traverse():
self.possible_oses.add(dep.os)
# add the hash to the one seen so far
self.seen_hashes.add(h)
@ -1764,6 +1767,8 @@ def hash(self, pkg, h):
assert concrete_spec, "Unable to look up concrete spec with hash %s" % h
self._specs[pkg] = concrete_spec
else:
# TODO: remove this code -- it's dead unless we decide that node() clauses
# should come before hashes.
# ensure that if it's already there, it's correct
spec = self._specs[pkg]
assert spec.dag_hash() == h

View File

@ -541,17 +541,20 @@ node_platform_set(Package) :- node_platform_set(Package, _).
os(OS) :- os(OS, _).
% one os per node
1 { node_os(Package, OS) : os(OS) } 1 :- node(Package), error("Each node must have exactly one OS").
1 { node_os(Package, OS) : os(OS) } 1 :-
node(Package), error("Each node must have exactly one OS").
% can't have a non-buildable OS on a node we need to build
:- build(Package), node_os(Package, OS), not buildable_os(OS).
:- build(Package), node_os(Package, OS), not buildable_os(OS),
error("No available OS can be built for").
% can't have dependencies on incompatible OS's
:- depends_on(Package, Dependency),
node_os(Package, PackageOS),
node_os(Dependency, DependencyOS),
not os_compatible(PackageOS, DependencyOS),
build(Package).
build(Package),
error("Dependencies must have compatible OS's with their dependents").
% give OS choice weights according to os declarations
node_os_weight(Package, Weight)
@ -641,7 +644,9 @@ node_target_mismatch(Parent, Dependency)
:- depends_on(Parent, Dependency),
not node_target_match(Parent, Dependency).
:- node(Package), node_target(Package, Target), not target(Target).
% disallow reusing concrete specs that don't have a compatible target
:- node(Package), node_target(Package, Target), not target(Target),
error("No satisfying package's target is compatible with this machine").
#defined node_target_set/2.
#defined package_target_weight/3.