Spec: Add a new virtual-customizable home attribute (#30917)
* Spec: Add a new virtual-customizable home attribute * java: Use the new builtin home attribute * python: Use the new builtin home attribute
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
|
||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
from spack.package import *
|
||||
|
||||
|
||||
class AttributesFooApp(BundlePackage):
|
||||
version('1.0')
|
||||
depends_on('bar')
|
||||
depends_on('baz')
|
||||
@@ -0,0 +1,69 @@
|
||||
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
|
||||
# Spack Project Developers. See the top-level COPYRIGHT file for details.
|
||||
#
|
||||
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
|
||||
|
||||
from spack.package import *
|
||||
|
||||
|
||||
class AttributesFoo(BundlePackage):
|
||||
phases = ['install']
|
||||
version('1.0')
|
||||
|
||||
provides('bar')
|
||||
provides('baz')
|
||||
|
||||
def install(self, spec, prefix):
|
||||
if 'platform=windows' in spec:
|
||||
lib_suffix = '.lib'
|
||||
elif 'platform=darwin' in spec:
|
||||
lib_suffix = '.dylib'
|
||||
else:
|
||||
lib_suffix = '.so'
|
||||
|
||||
mkdirp(prefix.include)
|
||||
touch(prefix.include.join('foo.h'))
|
||||
mkdirp(prefix.include.bar)
|
||||
touch(prefix.include.bar.join('bar.h'))
|
||||
mkdirp(prefix.lib64)
|
||||
touch(prefix.lib64.join('libFoo' + lib_suffix))
|
||||
touch(prefix.lib64.join('libFooBar' + lib_suffix))
|
||||
mkdirp(prefix.baz.include.baz)
|
||||
touch(prefix.baz.include.baz.join('baz.h'))
|
||||
mkdirp(prefix.baz.lib)
|
||||
touch(prefix.baz.lib.join('libFooBaz' + lib_suffix))
|
||||
|
||||
# Headers provided by Foo
|
||||
@property
|
||||
def headers(self):
|
||||
return find_headers('foo', root=self.home.include, recursive=False)
|
||||
|
||||
# Libraries provided by Foo
|
||||
@property
|
||||
def libs(self):
|
||||
return find_libraries('libFoo', root=self.home, recursive=True)
|
||||
|
||||
# Header provided by the bar virutal package
|
||||
@property
|
||||
def bar_headers(self):
|
||||
return find_headers('bar/bar', root=self.home.include, recursive=False)
|
||||
|
||||
# Libary provided by the bar virtual package
|
||||
@property
|
||||
def bar_libs(self):
|
||||
return find_libraries('libFooBar', root=self.home, recursive=True)
|
||||
|
||||
# The baz virtual package home
|
||||
@property
|
||||
def baz_home(self):
|
||||
return self.home.baz
|
||||
|
||||
# Header provided by the baz virtual package
|
||||
@property
|
||||
def baz_headers(self):
|
||||
return find_headers('baz/baz', root=self.baz_home.include, recursive=False)
|
||||
|
||||
# Library provided by the baz virtual package
|
||||
@property
|
||||
def baz_libs(self):
|
||||
return find_libraries('libFooBaz', root=self.baz_home, recursive=True)
|
||||
Reference in New Issue
Block a user