summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2020-01-02 19:51:19 -0800
committerTodd Gamblin <tgamblin@llnl.gov>2020-11-17 10:04:13 -0800
commit9b1f05df009123ae03b2a9c7971a06e148c4e56c (patch)
treed8ec30468760760087b70d20bcb2fe53f20e4529 /lib
parente31be3da565dd353cdb75db195c047ab154a8b56 (diff)
downloadspack-9b1f05df009123ae03b2a9c7971a06e148c4e56c.tar.gz
spack-9b1f05df009123ae03b2a9c7971a06e148c4e56c.tar.bz2
spack-9b1f05df009123ae03b2a9c7971a06e148c4e56c.tar.xz
spack-9b1f05df009123ae03b2a9c7971a06e148c4e56c.zip
concretizer bugfix: fix generations of conditionals for dependencies
Spack was generating the same dependency connstraints twice in the output ASP: ``` declared_dependency("abinit", "hdf5", "link") :- node("abinit"), variant_value("abinit", "mpi", "True"), variant_value("abinit", "mpi", "True"). ``` This was because `AspFunction` was modifying itself when called. - [x] fix `AspFunction` so that every call returns a new object
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/solver/asp.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/spack/spack/solver/asp.py b/lib/spack/spack/solver/asp.py
index 969e1997df..7701f38620 100644
--- a/lib/spack/spack/solver/asp.py
+++ b/lib/spack/spack/solver/asp.py
@@ -73,13 +73,12 @@ def _id(thing):
class AspFunction(AspObject):
- def __init__(self, name):
+ def __init__(self, name, args=None):
self.name = name
- self.args = []
+ self.args = [] if args is None else args
def __call__(self, *args):
- self.args[:] = args
- return self
+ return AspFunction(self.name, args)
def __getitem___(self, *args):
self.args[:] = args
@@ -89,6 +88,9 @@ class AspFunction(AspObject):
return "%s(%s)" % (
self.name, ', '.join(_id(arg) for arg in self.args))
+ def __repr__(self):
+ return str(self)
+
class AspAnd(AspObject):
def __init__(self, *args):
@@ -394,6 +396,7 @@ class AspGenerator(object):
*self.spec_clauses(named_cond, body=True)
)
)
+ self.out.write('\n')
# virtual preferences
self.virtual_preferences(