Papi packge: refactored to inherit from AutotoolsPackage (#15962)

This commit is contained in:
G-Ragghianti 2020-04-09 03:13:35 -04:00 committed by GitHub
parent 93a53f1faf
commit f9c833e078
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -10,7 +10,7 @@
from llnl.util.filesystem import fix_darwin_install_name from llnl.util.filesystem import fix_darwin_install_name
class Papi(Package): class Papi(AutotoolsPackage):
"""PAPI provides the tool designer and application engineer with a """PAPI provides the tool designer and application engineer with a
consistent interface and methodology for use of the performance consistent interface and methodology for use of the performance
counter hardware found in most major microprocessors. PAPI counter hardware found in most major microprocessors. PAPI
@ -42,53 +42,54 @@ class Papi(Package):
depends_on('lm-sensors', when='+lmsensors') depends_on('lm-sensors', when='+lmsensors')
conflicts('%gcc@8:', when='@5.3.0', msg='Requires GCC version less than 8.0')
# Does not build with newer versions of gcc, see # Does not build with newer versions of gcc, see
# https://bitbucket.org/icl/papi/issues/46/cannot-compile-on-arch-linux # https://bitbucket.org/icl/papi/issues/46/cannot-compile-on-arch-linux
patch('https://bitbucket.org/icl/papi/commits/53de184a162b8a7edff48fed01a15980664e15b1/raw', sha256='64c57b3ad4026255238cc495df6abfacc41de391a0af497c27d0ac819444a1f8', when='@5.4.0:5.6.99%gcc@8:') patch('https://bitbucket.org/icl/papi/commits/53de184a162b8a7edff48fed01a15980664e15b1/raw', sha256='64c57b3ad4026255238cc495df6abfacc41de391a0af497c27d0ac819444a1f8', when='@5.4.0:5.6.99%gcc@8:')
configure_directory = 'src'
def setup_build_environment(self, env): def setup_build_environment(self, env):
if '+lmsensors' in self.spec and self.version >= Version('6'): if '+lmsensors' in self.spec and self.version >= Version('6'):
env.set('PAPI_LMSENSORS_ROOT', self.spec['lm-sensors'].prefix) env.set('PAPI_LMSENSORS_ROOT', self.spec['lm-sensors'].prefix)
def setup_run_environment(self, env): setup_run_environment = setup_build_environment
if '+lmsensors' in self.spec and self.version >= Version('6'):
env.set('PAPI_LMSENSORS_ROOT', self.spec['lm-sensors'].prefix)
def install(self, spec, prefix):
if '+lmsensors' in spec:
if self.version < Version('6'):
with working_dir("src/components/lmsensors"):
configure_args = [
"--with-sensors_incdir=%s/sensors" %
spec['lm-sensors'].headers.directories[0],
"--with-sensors_libdir=%s" %
spec['lm-sensors'].libs.directories[0]]
configure(*configure_args)
with working_dir("src"):
configure_args = ["--prefix=%s" % prefix]
def configure_args(self):
# PAPI uses MPI if MPI is present; since we don't require # PAPI uses MPI if MPI is present; since we don't require
# an MPI package, we ensure that all attempts to use MPI # an MPI package, we ensure that all attempts to use MPI
# fail, so that PAPI does not get confused # fail, so that PAPI does not get confused
configure_args.append('MPICC=:') options = ['MPICC=:']
# Build a list of activated variants (optional PAPI components)
variants = filter(lambda x: self.spec.variants[x].value is True,
self.spec.variants)
if variants:
options.append('--with-components={0}'.format(' '.join(variants)))
return options
configure_args.append( @run_before('configure')
'--with-components={0}'.format(' '.join( def component_configure(self):
filter(lambda x: spec.variants[x].value, spec.variants)))) configure_script = Executable('./configure')
if '+lmsensors' in self.spec and self.version < Version('6'):
configure(*configure_args) with working_dir("src/components/lmsensors"):
configure_script(
"--with-sensors_incdir=%s/sensors" %
self.spec['lm-sensors'].headers.directories[0],
"--with-sensors_libdir=%s" %
self.spec['lm-sensors'].libs.directories[0])
@run_before('build')
def fix_build(self):
# Don't use <malloc.h> # Don't use <malloc.h>
for level in [".", "*", "*/*"]: for level in [".", "*", "*/*"]:
files = glob.iglob(join_path(level, "*.[ch]")) files = glob.iglob(join_path(level, "*.[ch]"))
filter_file(r"\<malloc\.h\>", "<stdlib.h>", *files) filter_file(r"\<malloc\.h\>", "<stdlib.h>", *files)
make() @run_after('install')
make("install") def fix_darwin_install(self):
# The shared library is not installed correctly on Darwin # The shared library is not installed correctly on Darwin
if sys.platform == 'darwin': if sys.platform == 'darwin':
os.rename(join_path(prefix.lib, 'libpapi.so'), os.rename(join_path(self.prefix.lib, 'libpapi.so'),
join_path(prefix.lib, 'libpapi.dylib')) join_path(self.prefix.lib, 'libpapi.dylib'))
fix_darwin_install_name(prefix.lib) fix_darwin_install_name(self.prefix.lib)