From 39a3cfd4d9fc8d0981ba118de9a1e049fba4b144 Mon Sep 17 00:00:00 2001 From: Massimiliano Culpo Date: Wed, 2 Dec 2015 12:24:37 +0100 Subject: reource directive accepts 'basename' keyword llvm : libc++ variant --- lib/spack/spack/directives.py | 5 ++++- lib/spack/spack/package.py | 3 ++- lib/spack/spack/resource.py | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py index 48a7df7462..07ef32294b 100644 --- a/lib/spack/spack/directives.py +++ b/lib/spack/spack/directives.py @@ -276,10 +276,12 @@ def resource(pkg, **kwargs): * '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, 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) destination = kwargs.get('destination', "") + basename = kwargs.get('basename', None) # Check if the path is relative if os.path.isabs(destination): 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, []) fetcher = from_kwargs(**kwargs) name = kwargs.get('name') - resources.append(Resource(name, fetcher, destination)) + resources.append(Resource(name, fetcher, destination, basename)) + class DirectiveError(spack.error.SpackError): """This is raised when something is wrong with a package directive.""" diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py index c10283a6ee..3f48231c75 100644 --- a/lib/spack/spack/package.py +++ b/lib/spack/spack/package.py @@ -681,7 +681,8 @@ class Package(object): for resource in resources: stage = resource.fetcher.stage _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): # Create a symlink os.symlink(stage.source_path, link_path) diff --git a/lib/spack/spack/resource.py b/lib/spack/spack/resource.py index 00ee2d49e4..b20612686d 100644 --- a/lib/spack/spack/resource.py +++ b/lib/spack/spack/resource.py @@ -27,11 +27,13 @@ Describes an optional resource needed for a build. Typically a bunch of sources package to enable optional features. """ + class Resource(object): """ 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.fetcher = fetcher self.destination = destination + self.basename = basename -- cgit v1.2.3-70-g09d2