summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authoralalazo <massimiliano.culpo@googlemail.com>2015-12-09 13:06:39 +0100
committeralalazo <massimiliano.culpo@googlemail.com>2015-12-09 17:15:26 +0100
commit20e67bc5e6c4a4ac759bb068ff78c13bfc17fb0f (patch)
treedfa48a18cf929b91610f563594fd6ed0650c8241 /lib
parent50bd4d2e4ed3fed83afa30e7796eaa99989bc3ce (diff)
downloadspack-20e67bc5e6c4a4ac759bb068ff78c13bfc17fb0f.tar.gz
spack-20e67bc5e6c4a4ac759bb068ff78c13bfc17fb0f.tar.bz2
spack-20e67bc5e6c4a4ac759bb068ff78c13bfc17fb0f.tar.xz
spack-20e67bc5e6c4a4ac759bb068ff78c13bfc17fb0f.zip
clang : solve the issue with missing default include paths for OpenMP and libc++
resource : support for finer grained linking of resources
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/directives.py17
-rw-r--r--lib/spack/spack/package.py16
-rw-r--r--lib/spack/spack/resource.py6
3 files changed, 23 insertions, 16 deletions
diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py
index 07ef32294b..22b262b57c 100644
--- a/lib/spack/spack/directives.py
+++ b/lib/spack/spack/directives.py
@@ -269,19 +269,20 @@ def variant(pkg, name, default=False, description=""):
def resource(pkg, **kwargs):
"""
Define an external resource to be fetched and staged when building the package. Based on the keywords present in the
- dictionary the appropriate FetchStrategy will be used for the resource.
+ dictionary the appropriate FetchStrategy will be used for the resource. Resources are fetched and staged in their
+ own folder inside spack stage area, and then linked into the stage area of the package that needs them.
List of recognized keywords:
- * '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' : (optional) represents the condition upon which the resource is needed
+ * 'destination' : (optional) path where to link the resource. This path must be relative to the main package stage
+ area.
+ * 'placement' : (optional) gives the possibility to fine tune how the resource is linked into the main package stage
+ area.
"""
when = kwargs.get('when', pkg.name)
destination = kwargs.get('destination', "")
- basename = kwargs.get('basename', None)
+ placement = kwargs.get('placement', 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"
@@ -298,7 +299,7 @@ def resource(pkg, **kwargs):
resources = pkg.resources.setdefault(when_spec, [])
fetcher = from_kwargs(**kwargs)
name = kwargs.get('name')
- resources.append(Resource(name, fetcher, destination, basename))
+ resources.append(Resource(name, fetcher, destination, placement))
class DirectiveError(spack.error.SpackError):
diff --git a/lib/spack/spack/package.py b/lib/spack/spack/package.py
index dcb514af00..b386f8f6a8 100644
--- a/lib/spack/spack/package.py
+++ b/lib/spack/spack/package.py
@@ -683,11 +683,17 @@ class Package(object):
for resource in resources:
stage = resource.fetcher.stage
_expand_archive(stage, resource.name)
- 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)
+ # Turn placement into a dict with relative paths
+ placement = os.path.basename(stage.source_path) if resource.placement is None else resource.placement
+ if not isinstance(placement, dict):
+ placement = {'': placement}
+ # Make the paths in the dictionary absolute and link
+ for key, value in placement.iteritems():
+ link_path = join_path(self.stage.source_path, resource.destination, value)
+ source_path = join_path(stage.source_path, key)
+ if not os.path.exists(link_path):
+ # Create a symlink
+ os.symlink(source_path, link_path)
##########
self.stage.chdir_to_source()
diff --git a/lib/spack/spack/resource.py b/lib/spack/spack/resource.py
index b20612686d..8d081b45c9 100644
--- a/lib/spack/spack/resource.py
+++ b/lib/spack/spack/resource.py
@@ -30,10 +30,10 @@ package to enable optional features.
class Resource(object):
"""
- Represents an optional resource. Aggregates a name, a fetcher and a destination.
+ Represents an optional resource. Aggregates a name, a fetcher, a destination and a placement
"""
- def __init__(self, name, fetcher, destination, basename):
+ def __init__(self, name, fetcher, destination, placement):
self.name = name
self.fetcher = fetcher
self.destination = destination
- self.basename = basename
+ self.placement = placement