reource directive accepts 'basename' keyword

llvm : libc++ variant
This commit is contained in:
Massimiliano Culpo 2015-12-02 12:24:37 +01:00
parent 4b2168ab8e
commit 39a3cfd4d9
4 changed files with 17 additions and 4 deletions

View file

@ -276,10 +276,12 @@ def resource(pkg, **kwargs):
* 'when' : represents the condition upon which the resource is needed (optional) * 'when' : represents the condition upon which the resource is needed (optional)
* 'destination' : path where to extract / checkout the resource (optional). This path must be a relative path, * 'destination' : path where to extract / checkout the resource (optional). This path must be a relative path,
and it must fall inside the stage area of the main package. and it must fall inside the stage area of the main package.
* 'basename' : basename of the resource source folder within destination (optional).
""" """
when = kwargs.get('when', pkg.name) when = kwargs.get('when', pkg.name)
destination = kwargs.get('destination', "") destination = kwargs.get('destination', "")
basename = kwargs.get('basename', None)
# Check if the path is relative # Check if the path is relative
if os.path.isabs(destination): if os.path.isabs(destination):
message = "The destination keyword of a resource directive can't be an absolute path.\n" message = "The destination keyword of a resource directive can't be an absolute path.\n"
@ -296,7 +298,8 @@ def resource(pkg, **kwargs):
resources = pkg.resources.setdefault(when_spec, []) resources = pkg.resources.setdefault(when_spec, [])
fetcher = from_kwargs(**kwargs) fetcher = from_kwargs(**kwargs)
name = kwargs.get('name') name = kwargs.get('name')
resources.append(Resource(name, fetcher, destination)) resources.append(Resource(name, fetcher, destination, basename))
class DirectiveError(spack.error.SpackError): class DirectiveError(spack.error.SpackError):
"""This is raised when something is wrong with a package directive.""" """This is raised when something is wrong with a package directive."""

View file

@ -681,7 +681,8 @@ def _expand_archive(stage, name=self.name):
for resource in resources: for resource in resources:
stage = resource.fetcher.stage stage = resource.fetcher.stage
_expand_archive(stage, resource.name) _expand_archive(stage, resource.name)
link_path = join_path(self.stage.source_path, resource.destination, os.path.basename(stage.source_path)) basename = os.path.basename(stage.source_path) if resource.basename is None else resource.basename
link_path = join_path(self.stage.source_path, resource.destination, basename)
if not os.path.exists(link_path): if not os.path.exists(link_path):
# Create a symlink # Create a symlink
os.symlink(stage.source_path, link_path) os.symlink(stage.source_path, link_path)

View file

@ -27,11 +27,13 @@
package to enable optional features. package to enable optional features.
""" """
class Resource(object): class Resource(object):
""" """
Represents an optional resource. Aggregates a name, a fetcher and a destination. Represents an optional resource. Aggregates a name, a fetcher and a destination.
""" """
def __init__(self, name, fetcher, destination): def __init__(self, name, fetcher, destination, basename):
self.name = name self.name = name
self.fetcher = fetcher self.fetcher = fetcher
self.destination = destination self.destination = destination
self.basename = basename

View file

@ -41,15 +41,22 @@ class Llvm(Package):
depends_on('python@2.7:') depends_on('python@2.7:')
variant('libcxx', default=False, description="Builds the LLVM Standard C++ library targeting C++11")
########## ##########
# @3.7.0 # @3.7.0
# TODO : Add support for libc++ <- libc++ABI <- libunwind with variant?
resource(name='compiler-rt', resource(name='compiler-rt',
url='http://llvm.org/releases/3.7.0/compiler-rt-3.7.0.src.tar.xz', md5='383c10affd513026f08936b5525523f5', url='http://llvm.org/releases/3.7.0/compiler-rt-3.7.0.src.tar.xz', md5='383c10affd513026f08936b5525523f5',
destination='projects', when='@3.7.0') destination='projects', when='@3.7.0')
resource(name='openmp', resource(name='openmp',
url='http://llvm.org/releases/3.7.0/openmp-3.7.0.src.tar.xz', md5='f482c86fdead50ba246a1a2b0bbf206f', url='http://llvm.org/releases/3.7.0/openmp-3.7.0.src.tar.xz', md5='f482c86fdead50ba246a1a2b0bbf206f',
destination='projects', when='@3.7.0') destination='projects', when='@3.7.0')
resource(name='libcxx',
url='http://llvm.org/releases/3.7.0/libcxx-3.7.0.src.tar.xz', md5='46aa5175cbe1ad42d6e9c995968e56dd',
destination='projects', basename='libcxx', when='+libcxx@3.7.0')
resource(name='libcxxabi',
url='http://llvm.org/releases/3.7.0/libcxxabi-3.7.0.src.tar.xz', md5='5aa769e2fca79fa5335cfae8f6258772',
destination='projects', basename='libcxxabi', when='+libcxx@3.7.0')
########## ##########
def install(self, spec, prefix): def install(self, spec, prefix):