summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2019-08-02 23:19:09 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2020-11-17 10:04:13 -0800
commit3637b611a7c4bf83a55dbf8c13f492234686b787 (patch)
treee3e436be8665bb503fb383a9577a07ad31bf0da6
parent81e187e41010e5691e770348c784058c88f7c837 (diff)
downloadspack-3637b611a7c4bf83a55dbf8c13f492234686b787.tar.gz
spack-3637b611a7c4bf83a55dbf8c13f492234686b787.tar.bz2
spack-3637b611a7c4bf83a55dbf8c13f492234686b787.tar.xz
spack-3637b611a7c4bf83a55dbf8c13f492234686b787.zip
concretizer: move dump logic into solver.asp
- moving the dump logic into spack.solver.asp.solve() allows us to print out useful debug info sooner - prior approach required a successful solve to print out anyhting.
-rw-r--r--lib/spack/spack/cmd/solve.py18
-rw-r--r--lib/spack/spack/solver/asp.py28
2 files changed, 25 insertions, 21 deletions
diff --git a/lib/spack/spack/cmd/solve.py b/lib/spack/spack/cmd/solve.py
index 8955f6b2a9..7fea75233d 100644
--- a/lib/spack/spack/cmd/solve.py
+++ b/lib/spack/spack/cmd/solve.py
@@ -93,24 +93,6 @@ def solve(parser, args):
if not result.satisfiable:
tty.die("Unsatisfiable spec.")
- # dump generated ASP program
- if 'asp' in dump:
- tty.msg('ASP program:')
- sys.stdout.write(result.asp)
-
- # dump any warnings generated by the solver
- if 'warnings' in dump:
- if result.warnings:
- tty.msg('Clingo gave the following warnings:')
- sys.stdout.write(result.warnings)
- else:
- tty.msg('No warnings.')
-
- # dump the raw output of the solver
- if 'output' in dump:
- tty.msg('Clingo output:')
- sys.stdout.write(result.output)
-
# dump the solutions as concretized specs
if 'solutions' in dump:
for i, answer in enumerate(result.answers):
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index 5407103b84..30268e5224 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -7,6 +7,7 @@ from __future__ import print_function
import collections
import re
+import sys
import tempfile
import types
from six import string_types
@@ -259,6 +260,10 @@ class AspGenerator(object):
self.fact(fn.arch_os(spec.name, arch.os))
self.fact(fn.arch_target(spec.name, arch.target))
+ # variants
+ for vname, variant in spec.variants.items():
+ self.fact(fn.variant_value(spec.name, vname, variant.value))
+
# TODO
# dependencies
# compiler
@@ -403,6 +408,10 @@ def solve(specs, dump=None, models=1):
result = Result(program.read())
program.seek(0)
+ if 'asp' in dump:
+ tty.msg('ASP program:')
+ sys.stdout.write(result.asp)
+
with tempfile.TemporaryFile("w+") as output:
with tempfile.TemporaryFile() as warnings:
clingo(
@@ -412,13 +421,26 @@ def solve(specs, dump=None, models=1):
error=warnings,
fail_on_error=False)
+ warnings.seek(0)
+ result.warnings = warnings.read()
+
+ # dump any warnings generated by the solver
+ if 'warnings' in dump:
+ if result.warnings:
+ tty.msg('Clingo gave the following warnings:')
+ sys.stdout.write(result.warnings)
+ else:
+ tty.msg('No warnings.')
+
output.seek(0)
result.output = output.read()
+ # dump the raw output of the solver
+ if 'output' in dump:
+ tty.msg('Clingo output:')
+ sys.stdout.write(result.output)
+
output.seek(0)
parser.parse(output, result)
- warnings.seek(0)
- result.warnings = warnings.read()
-
return result