clang : solve the issue with missing default include paths for OpenMP and libc++
resource : support for finer grained linking of resources
This commit is contained in:
@@ -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):
|
||||
|
@@ -683,11 +683,17 @@ def _expand_archive(stage, name=self.name):
|
||||
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()
|
||||
|
||||
|
@@ -30,10 +30,10 @@
|
||||
|
||||
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
|
||||
|
Reference in New Issue
Block a user