summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-08-10 19:26:00 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2020-11-17 10:04:13 -0800
commit34ea3d20cf6d4af8217e0135b504b258b8531874 (patch)
treee497902833d570c6cca4b2400523d75adb52fb7d
parentd94d9575360ad3a5078263fc63b5876f92237a3a (diff)
downloadspack-34ea3d20cf6d4af8217e0135b504b258b8531874.tar.gz
spack-34ea3d20cf6d4af8217e0135b504b258b8531874.tar.bz2
spack-34ea3d20cf6d4af8217e0135b504b258b8531874.tar.xz
spack-34ea3d20cf6d4af8217e0135b504b258b8531874.zip
concretizer: break output up into easier-to-understand sections
-rw-r--r--lib/spack/spack/solver/asp.py31
-rw-r--r--lib/spack/spack/solver/concretize.lp24
-rw-r--r--lib/spack/spack/solver/display.lp4
3 files changed, 37 insertions, 22 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index dff1f385c7..12ad5812c8 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -112,14 +112,20 @@ class AspGenerator(object):
self.out = out
self.func = AspFunctionBuilder()
- def title(self, name):
+ def title(self, name, char):
self.out.write('\n')
- self.out.write("%" + ("-" * 76))
+ self.out.write("%" + (char * 76))
self.out.write('\n')
self.out.write("%% %s\n" % name)
- self.out.write("%" + ("-" * 76))
+ self.out.write("%" + (char * 76))
self.out.write('\n')
+ def h1(self, name):
+ self.title(name, "=")
+
+ def h2(self, name):
+ self.title(name, "-")
+
def section(self, name):
self.out.write("\n")
self.out.write("%\n")
@@ -186,6 +192,7 @@ class AspGenerator(object):
# versions
self.pkg_version_rules(pkg)
+ self.out.write('\n')
# variants
for name, variant in pkg.variants.items():
@@ -258,23 +265,23 @@ class AspGenerator(object):
pkgs = list(set(spack.package.possible_dependencies(*pkgs))
| set(pkg_names))
- self.out.write(pkgutil.get_data('spack.solver', 'concretize.lp'))
+ concretize_lp = pkgutil.get_data('spack.solver', 'concretize.lp')
+ self.out.write(concretize_lp.decode("utf-8"))
- self.title('Package Constraints')
+ self.h1('Package Constraints')
for pkg in pkgs:
- self.section('Package: %s' % pkg)
+ self.h2('Package: %s' % pkg)
self.pkg_rules(pkg)
- self.out.write('\n')
- self.title('Spec Constraints')
+ self.h1('Spec Constraints')
for spec in specs:
for dep in spec.traverse():
- self.section('Spec: %s' % str(dep))
+ self.h2('Spec: %s' % str(dep))
self.spec_rules(dep)
- self.out.write('\n')
- self.out.write(pkgutil.get_data('spack.solver', 'display.lp'))
self.out.write('\n')
+ display_lp = pkgutil.get_data('spack.solver', 'display.lp')
+ self.out.write(display_lp.decode("utf-8"))
class ResultParser(object):
@@ -375,7 +382,7 @@ def highlight(string):
string = re.sub(r'(\w[\w-]+)\(([^)]*)\)', r'@C{\1}@w{(}\2@w{)}', string)
# comments
- string = re.sub(r'(%.*)$', r'@K\1@.', string, flags=re.MULTILINE)
+ string = re.sub(r'(%.*)$', r'@w\1@.', string, flags=re.MULTILINE)
# strings
string = re.sub(r'("[^"]*")', r'@m{\1}', string)
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp
index 15c061ef20..6719eef7f2 100644
--- a/lib/spack/spack/solver/concretize.lp
+++ b/lib/spack/spack/solver/concretize.lp
@@ -1,6 +1,6 @@
-% -----------------------------------------
+%=============================================================================
% Generate
-% -----------------------------------------
+%=============================================================================
% One version, arch, etc. per package
{ version(P, V) : version(P, V)} = 1 :- node(P).
{ arch_platform(P, A) : arch_platform(P, A) } = 1 :- node(P).
@@ -11,16 +11,15 @@
{ variant_value(P, V, X) : variant_value(P, V, X) } = 1
:- node(P), variant(P, V), not variant_single_value(P, V).
-% -----------------------------------------
+%=============================================================================
% Define
-% -----------------------------------------
+%=============================================================================
% dependencies imply new nodes.
node(D) :- node(P), depends_on(P, D).
-% propagate platform, os, target downwards
-arch_platform(D, A) :- node(D), depends_on(P, D), arch_platform(P, A).
-arch_os(D, A) :- node(D), depends_on(P, D), arch_os(P, A).
-arch_target(D, A) :- node(D), depends_on(P, D), arch_target(P, A).
+%-----------------------------------------------------------------------------
+% Variant semantics
+%-----------------------------------------------------------------------------
% if a variant is set to anything, it is considered 'set'.
variant_set(P, V) :- variant_set(P, V, _).
@@ -35,3 +34,12 @@ variant_set(P, V) :- variant_set(P, V, _).
variant_value(P, V, X) :- node(P), variant(P, V), variant_set(P, V, X).
variant_value(P, V, X) :- node(P), variant(P, V), not variant_set(P, V),
variant_default_value(P, V, X).
+
+%-----------------------------------------------------------------------------
+% Architecture semantics
+%-----------------------------------------------------------------------------
+
+% propagate platform, os, target downwards
+arch_platform(D, A) :- node(D), depends_on(P, D), arch_platform(P, A).
+arch_os(D, A) :- node(D), depends_on(P, D), arch_os(P, A).
+arch_target(D, A) :- node(D), depends_on(P, D), arch_target(P, A).
diff --git a/lib/spack/spack/solver/display.lp b/lib/spack/spack/solver/display.lp
index b9a8b4b158..61f12cd6fd 100644
--- a/lib/spack/spack/solver/display.lp
+++ b/lib/spack/spack/solver/display.lp
@@ -1,8 +1,8 @@
-% ----------------------------------------------------------------------------
+%=============================================================================-
% Display Results
%
% This section determines what parts of the model are printed at the end
-% ----------------------------------------------------------------------------
+%==============================================================================
#show node/1.
#show depends_on/2.
#show version/2.