diff options
author | becker33 <becker33@llnl.gov> | 2016-02-25 13:38:03 -0800 |
---|---|---|
committer | becker33 <becker33@llnl.gov> | 2016-02-25 13:38:03 -0800 |
commit | 7176e5ef074ee267fa976fcaad0b6237d3b22f06 (patch) | |
tree | bce59904186adfd56a23b4ec5a9c19a24ce08b47 | |
parent | 0d23ff92b081ac5a580a684ab13d3d98b9b55620 (diff) | |
parent | 0cf03518f3edf8b70331b1b5f2eae171d0a0dccf (diff) | |
download | spack-7176e5ef074ee267fa976fcaad0b6237d3b22f06.tar.gz spack-7176e5ef074ee267fa976fcaad0b6237d3b22f06.tar.bz2 spack-7176e5ef074ee267fa976fcaad0b6237d3b22f06.tar.xz spack-7176e5ef074ee267fa976fcaad0b6237d3b22f06.zip |
Merge pull request #299 from epfl-scitas/enhancement/os_detection
enhancement proposal : boolean support for when=<arg>
-rw-r--r-- | lib/spack/spack/directives.py | 6 | ||||
-rw-r--r-- | lib/spack/spack/multimethod.py | 9 |
2 files changed, 11 insertions, 4 deletions
diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py index 5745adce63..c8542f55f0 100644 --- a/lib/spack/spack/directives.py +++ b/lib/spack/spack/directives.py @@ -174,7 +174,11 @@ def version(pkg, ver, checksum=None, **kwargs): def _depends_on(pkg, spec, when=None): - if when is None: + # If when is False do nothing + if when is False: + return + # If when is None or True make sure the condition is always satisfied + if when is None or when is True: when = pkg.name when_spec = parse_anonymous_spec(when, pkg.name) diff --git a/lib/spack/spack/multimethod.py b/lib/spack/spack/multimethod.py index df9b9b2ab1..51c6a8e89d 100644 --- a/lib/spack/spack/multimethod.py +++ b/lib/spack/spack/multimethod.py @@ -193,10 +193,11 @@ class when(object): platform-specific versions. There's not much we can do to get around this because of the way decorators work. """ -class when(object): def __init__(self, spec): pkg = get_calling_module_name() - self.spec = parse_anonymous_spec(spec, pkg) + if spec is True: + spec = pkg + self.spec = parse_anonymous_spec(spec, pkg) if spec is not False else None def __call__(self, method): # Get the first definition of the method in the calling scope @@ -207,7 +208,9 @@ class when(object): if not type(original_method) == SpecMultiMethod: original_method = SpecMultiMethod(original_method) - original_method.register(self.spec, method) + if self.spec is not None: + original_method.register(self.spec, method) + return original_method |