depends_on and when multimethod support boolean
This commit is contained in:
parent
3c64c18bfc
commit
bf4231dd4b
@ -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)
|
||||
|
||||
|
@ -193,10 +193,11 @@ def install(self, prefix):
|
||||
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 @@ def __call__(self, method):
|
||||
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
|
||||
|
||||
|
||||
|
46
lib/spack/spack/util/architecture.py
Normal file
46
lib/spack/spack/util/architecture.py
Normal file
@ -0,0 +1,46 @@
|
||||
##############################################################################
|
||||
# Copyright (c) 2013, Lawrence Livermore National Security, LLC.
|
||||
# Produced at the Lawrence Livermore National Laboratory.
|
||||
#
|
||||
# This file is part of Spack.
|
||||
# Written by Todd Gamblin, tgamblin@llnl.gov, All rights reserved.
|
||||
# LLNL-CODE-647188
|
||||
#
|
||||
# For details, see https://github.com/llnl/spack
|
||||
# Please also see the LICENSE file for our notice and the LGPL.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License (as published by
|
||||
# the Free Software Foundation) version 2.1 dated February 1999.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the terms and
|
||||
# conditions of the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
##############################################################################
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
def os_is_in(*args):
|
||||
"""
|
||||
Return True if any element in the list is equal to sys.platform, False otherwise
|
||||
|
||||
:param args: list of names to be checked
|
||||
:return: True or False
|
||||
"""
|
||||
return any(map(lambda x: x == sys.platform, args))
|
||||
|
||||
|
||||
def os_is_not_in(*args):
|
||||
"""
|
||||
Return True if none of the elements in the list is equal to sys.platform, False otherwise
|
||||
|
||||
:param args: list of names to be checked
|
||||
:return: True or False
|
||||
"""
|
||||
return not os_is_in(*args)
|
@ -1,5 +1,7 @@
|
||||
from spack import *
|
||||
|
||||
import spack.util.architecture as arch
|
||||
|
||||
class Openssl(Package):
|
||||
"""The OpenSSL Project is a collaborative effort to develop a
|
||||
robust, commercial-grade, full-featured, and Open Source
|
||||
@ -26,3 +28,16 @@ def install(self, spec, prefix):
|
||||
|
||||
make()
|
||||
make("install")
|
||||
|
||||
@when(arch.os_is_in('darwin'))
|
||||
def install(self, spec, prefix):
|
||||
perl = which('perl')
|
||||
perl("./Configure",
|
||||
"--prefix=%s" % prefix,
|
||||
"--openssldir=%s/etc/openssl" % prefix,
|
||||
"zlib",
|
||||
"no-krb5",
|
||||
"shared",
|
||||
"darwin64-x86_64-cc")
|
||||
filter_file(r'-arch x86_64', '', 'Makefile')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user