Add bindist tests for macOS.

This commit is contained in:
Patrick Gartung 2020-08-01 18:02:39 -05:00 committed by Todd Gamblin
parent ef3338a49b
commit f29dd48101
4 changed files with 109 additions and 50 deletions

View File

@ -7,6 +7,7 @@
This test checks creating and install buildcaches This test checks creating and install buildcaches
""" """
import os import os
import sys
import py import py
import pytest import pytest
import argparse import argparse
@ -158,8 +159,14 @@ def install_dir_non_default_layout(tmpdir):
spack.store.layout = real_layout spack.store.layout = real_layout
@pytest.mark.requires_executables( args = ['strings', 'file']
'/usr/bin/gcc', 'patchelf', 'strings', 'file') if sys.platform == 'darwin':
args.extend(['/usr/bin/clang++', 'install_name_tool'])
else:
args.extend(['/usr/bin/g++', 'patchelf'])
@pytest.mark.requires_executables(*args)
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
@pytest.mark.maybeslow @pytest.mark.maybeslow
@pytest.mark.usefixtures('default_config', 'cache_directory', @pytest.mark.usefixtures('default_config', 'cache_directory',
@ -177,7 +184,6 @@ def test_default_rpaths_create_install_default_layout(tmpdir,
cspec = Spec('corge') cspec = Spec('corge')
cspec.concretize() cspec.concretize()
# Install patchelf needed for relocate in linux test environment
iparser = argparse.ArgumentParser() iparser = argparse.ArgumentParser()
install.setup_parser(iparser) install.setup_parser(iparser)
# Install some packages with dependent packages # Install some packages with dependent packages
@ -253,8 +259,7 @@ def test_default_rpaths_create_install_default_layout(tmpdir,
mirror.mirror(mparser, margs) mirror.mirror(mparser, margs)
@pytest.mark.requires_executables( @pytest.mark.requires_executables(*args)
'/usr/bin/gcc', 'patchelf', 'strings', 'file')
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
@pytest.mark.maybeslow @pytest.mark.maybeslow
@pytest.mark.nomockstage @pytest.mark.nomockstage
@ -302,8 +307,7 @@ def test_default_rpaths_install_nondefault_layout(tmpdir,
mirror.mirror(mparser, margs) mirror.mirror(mparser, margs)
@pytest.mark.requires_executables( @pytest.mark.requires_executables(*args)
'/usr/bin/gcc', 'patchelf', 'strings', 'file')
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
@pytest.mark.maybeslow @pytest.mark.maybeslow
@pytest.mark.nomockstage @pytest.mark.nomockstage
@ -356,8 +360,7 @@ def test_relative_rpaths_create_default_layout(tmpdir,
spack.stage.purge() spack.stage.purge()
@pytest.mark.requires_executables( @pytest.mark.requires_executables(*args)
'/usr/bin/gcc', 'patchelf', 'strings', 'file')
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
@pytest.mark.maybeslow @pytest.mark.maybeslow
@pytest.mark.nomockstage @pytest.mark.nomockstage
@ -382,7 +385,6 @@ def test_relative_rpaths_install_default_layout(tmpdir,
['add', '--scope', 'site', 'test-mirror-rel', 'file://%s' % mirror_path_rel]) ['add', '--scope', 'site', 'test-mirror-rel', 'file://%s' % mirror_path_rel])
mirror.mirror(mparser, margs) mirror.mirror(mparser, margs)
# Install patchelf needed for relocate in linux test environment
iparser = argparse.ArgumentParser() iparser = argparse.ArgumentParser()
install.setup_parser(iparser) install.setup_parser(iparser)
@ -422,8 +424,7 @@ def test_relative_rpaths_install_default_layout(tmpdir,
mirror.mirror(mparser, margs) mirror.mirror(mparser, margs)
@pytest.mark.requires_executables( @pytest.mark.requires_executables(*args)
'/usr/bin/gcc', 'patchelf', 'strings', 'file')
@pytest.mark.disable_clean_stage_check @pytest.mark.disable_clean_stage_check
@pytest.mark.maybeslow @pytest.mark.maybeslow
@pytest.mark.nomockstage @pytest.mark.nomockstage
@ -449,7 +450,6 @@ def test_relative_rpaths_install_nondefault(tmpdir,
['add', '--scope', 'site', 'test-mirror-rel', 'file://%s' % mirror_path_rel]) ['add', '--scope', 'site', 'test-mirror-rel', 'file://%s' % mirror_path_rel])
mirror.mirror(mparser, margs) mirror.mirror(mparser, margs)
# Install patchelf needed for relocate in linux test environment
iparser = argparse.ArgumentParser() iparser = argparse.ArgumentParser()
install.setup_parser(iparser) install.setup_parser(iparser)

View File

@ -6,6 +6,7 @@
from spack import * from spack import *
import os import os
import sys
class Corge(Package): class Corge(Package):
@ -101,7 +102,6 @@ class Corge
return 0; return 0;
} }
''' '''
mkdirp(prefix.lib64)
mkdirp('%s/corge' % prefix.include) mkdirp('%s/corge' % prefix.include)
mkdirp('%s/corge' % self.stage.source_path) mkdirp('%s/corge' % self.stage.source_path)
with open('%s/corge_version.h' % self.stage.source_path, 'w') as f: with open('%s/corge_version.h' % self.stage.source_path, 'w') as f:
@ -113,6 +113,8 @@ class Corge
with open('%s/corge/corgegator.cc' % self.stage.source_path, 'w') as f: with open('%s/corge/corgegator.cc' % self.stage.source_path, 'w') as f:
f.write(corgegator_cc) f.write(corgegator_cc)
gpp = which('/usr/bin/g++') gpp = which('/usr/bin/g++')
if sys.platform == 'darwin':
gpp = which('/usr/bin/clang++')
gpp('-Dcorge_EXPORTS', gpp('-Dcorge_EXPORTS',
'-I%s' % self.stage.source_path, '-I%s' % self.stage.source_path,
'-I%s' % spec['quux'].prefix.include, '-I%s' % spec['quux'].prefix.include,
@ -127,22 +129,42 @@ class Corge
'-O2', '-g', '-DNDEBUG', '-fPIC', '-O2', '-g', '-DNDEBUG', '-fPIC',
'-o', 'corgegator.cc.o', '-o', 'corgegator.cc.o',
'-c', 'corge/corgegator.cc') '-c', 'corge/corgegator.cc')
gpp('-fPIC', '-O2', '-g', '-DNDEBUG', '-shared', if sys.platform == 'darwin':
'-Wl,-soname,libcorge.so', '-o', 'libcorge.so', 'corge.cc.o', gpp('-fPIC', '-O2', '-g', '-DNDEBUG', '-dynamiclib',
'-Wl,-rpath,%s:%s::::' % '-install_name', '@rpath/libcorge.dylib',
(spec['quux'].prefix.lib64, spec['garply'].prefix.lib64), '-o', 'libcorge.dylib', 'corge.cc.o',
'%s/libquux.so' % spec['quux'].prefix.lib64, '-Wl,-rpath,%s' % spec['quux'].prefix.lib64,
'%s/libgarply.so' % spec['garply'].prefix.lib64) '-Wl,-rpath,%s' % spec['garply'].prefix.lib64,
gpp('-O2', '-g', '-DNDEBUG', '-rdynamic', '%s/libquux.dylib' % spec['quux'].prefix.lib64,
'corgegator.cc.o', '-o', 'corgegator', '%s/libgarply.dylib' % spec['garply'].prefix.lib64)
'-Wl,-rpath,%s:%s:%s:::' % (prefix.lib64, gpp('-O2', '-g', '-DNDEBUG', '-rdynamic',
spec['quux'].prefix.lib64, 'corgegator.cc.o', '-o', 'corgegator',
spec['garply'].prefix.lib64), '-Wl,-rpath,%s' % prefix.lib64,
'libcorge.so', '-Wl,-rpath,%s' % spec['quux'].prefix.lib64,
'%s/libquux.so' % spec['quux'].prefix.lib64, '-Wl,-rpath,%s' % spec['garply'].prefix.lib64,
'%s/libgarply.so' % spec['garply'].prefix.lib64) 'libcorge.dylib',
'%s/libquux.dylib' % spec['quux'].prefix.lib64,
'%s/libgarply.dylib' % spec['garply'].prefix.lib64)
mkdirp(prefix.lib64)
copy('libcorge.dylib', '%s/libcorge.dylib' % prefix.lib64)
else:
gpp('-fPIC', '-O2', '-g', '-DNDEBUG', '-shared',
'-Wl,-soname,libcorge.so', '-o', 'libcorge.so', 'corge.cc.o',
'-Wl,-rpath,%s:%s::::' %
(spec['quux'].prefix.lib64, spec['garply'].prefix.lib64),
'%s/libquux.so' % spec['quux'].prefix.lib64,
'%s/libgarply.so' % spec['garply'].prefix.lib64)
gpp('-O2', '-g', '-DNDEBUG', '-rdynamic',
'corgegator.cc.o', '-o', 'corgegator',
'-Wl,-rpath,%s' % prefix.lib64,
'-Wl,-rpath,%s' % spec['quux'].prefix.lib64,
'-Wl,-rpath,%s' % spec['garply'].prefix.lib64,
'libcorge.so',
'%s/libquux.so' % spec['quux'].prefix.lib64,
'%s/libgarply.so' % spec['garply'].prefix.lib64)
mkdirp(prefix.lib64)
copy('libcorge.so', '%s/libcorge.so' % prefix.lib64)
copy('corgegator', '%s/corgegator' % prefix.lib64) copy('corgegator', '%s/corgegator' % prefix.lib64)
copy('libcorge.so', '%s/libcorge.so' % prefix.lib64)
copy('%s/corge/corge.h' % self.stage.source_path, copy('%s/corge/corge.h' % self.stage.source_path,
'%s/corge/corge.h' % prefix.include) '%s/corge/corge.h' % prefix.include)
mkdirp(prefix.bin) mkdirp(prefix.bin)

View File

@ -6,6 +6,7 @@
from spack import * from spack import *
import os import os
import sys
class Garply(Package): class Garply(Package):
@ -73,7 +74,6 @@ class Garply
garply_version_h = '''const int garply_version_major = %s; garply_version_h = '''const int garply_version_major = %s;
const int garply_version_minor = %s; const int garply_version_minor = %s;
''' '''
mkdirp(prefix.lib64)
mkdirp('%s/garply' % prefix.include) mkdirp('%s/garply' % prefix.include)
mkdirp('%s/garply' % self.stage.source_path) mkdirp('%s/garply' % self.stage.source_path)
with open('%s/garply_version.h' % self.stage.source_path, 'w') as f: with open('%s/garply_version.h' % self.stage.source_path, 'w') as f:
@ -86,6 +86,8 @@ class Garply
self.stage.source_path, 'w') as f: self.stage.source_path, 'w') as f:
f.write(garplinator_cc) f.write(garplinator_cc)
gpp = which('/usr/bin/g++') gpp = which('/usr/bin/g++')
if sys.platform == 'darwin':
gpp = which('/usr/bin/clang++')
gpp('-Dgarply_EXPORTS', gpp('-Dgarply_EXPORTS',
'-I%s' % self.stage.source_path, '-I%s' % self.stage.source_path,
'-O2', '-g', '-DNDEBUG', '-fPIC', '-O2', '-g', '-DNDEBUG', '-fPIC',
@ -96,13 +98,28 @@ class Garply
'-O2', '-g', '-DNDEBUG', '-fPIC', '-O2', '-g', '-DNDEBUG', '-fPIC',
'-o', 'garplinator.cc.o', '-o', 'garplinator.cc.o',
'-c', '%s/garply/garplinator.cc' % self.stage.source_path) '-c', '%s/garply/garplinator.cc' % self.stage.source_path)
gpp('-fPIC', '-O2', '-g', '-DNDEBUG', '-shared', if sys.platform == 'darwin':
'-Wl,-soname,libgarply.so', '-o', 'libgarply.so', 'garply.cc.o') gpp('-fPIC', '-O2', '-g', '-DNDEBUG', '-dynamiclib',
gpp('-O2', '-g', '-DNDEBUG', '-rdynamic', '-Wl,-headerpad_max_install_names', '-o', 'libgarply.dylib',
'garplinator.cc.o', '-o', 'garplinator', '-install_name', '@rpath/libgarply.dylib',
'-Wl,-rpath,%s' % prefix.lib64, 'garply.cc.o')
'libgarply.so') gpp('-O2', '-g', '-DNDEBUG', '-Wl,-search_paths_first',
copy('libgarply.so', '%s/libgarply.so' % prefix.lib64) '-Wl,-headerpad_max_install_names',
'garplinator.cc.o', '-o', 'garplinator',
'-Wl,-rpath,%s' % prefix.lib64,
'libgarply.dylib')
mkdirp(prefix.lib64)
copy('libgarply.dylib', '%s/libgarply.dylib' % prefix.lib64)
else:
gpp('-fPIC', '-O2', '-g', '-DNDEBUG', '-shared',
'-Wl,-soname,libgarply.so',
'-o', 'libgarply.so', 'garply.cc.o')
gpp('-O2', '-g', '-DNDEBUG', '-rdynamic',
'garplinator.cc.o', '-o', 'garplinator',
'-Wl,-rpath,%s' % prefix.lib64,
'libgarply.so')
mkdirp(prefix.lib64)
copy('libgarply.so', '%s/libgarply.so' % prefix.lib64)
copy('garplinator', '%s/garplinator' % prefix.lib64) copy('garplinator', '%s/garplinator' % prefix.lib64)
copy('%s/garply/garply.h' % self.stage.source_path, copy('%s/garply/garply.h' % self.stage.source_path,
'%s/garply/garply.h' % prefix.include) '%s/garply/garply.h' % prefix.include)

View File

@ -6,6 +6,7 @@
from spack import * from spack import *
import os import os
import sys
class Quux(Package): class Quux(Package):
@ -87,7 +88,6 @@ class Quux
quux_version_h = '''const int quux_version_major = %s; quux_version_h = '''const int quux_version_major = %s;
const int quux_version_minor = %s; const int quux_version_minor = %s;
''' '''
mkdirp(prefix.lib64)
mkdirp('%s/quux' % prefix.include) mkdirp('%s/quux' % prefix.include)
with open('%s/quux_version.h' % self.stage.source_path, 'w') as f: with open('%s/quux_version.h' % self.stage.source_path, 'w') as f:
f.write(quux_version_h % (self.version[0], self.version[1:])) f.write(quux_version_h % (self.version[0], self.version[1:]))
@ -98,6 +98,8 @@ class Quux
with open('%s/quux/quuxifier.cc' % self.stage.source_path, 'w') as f: with open('%s/quux/quuxifier.cc' % self.stage.source_path, 'w') as f:
f.write(quuxifier_cc) f.write(quuxifier_cc)
gpp = which('/usr/bin/g++') gpp = which('/usr/bin/g++')
if sys.platform == 'darwin':
gpp = which('/usr/bin/clang++')
gpp('-Dquux_EXPORTS', gpp('-Dquux_EXPORTS',
'-I%s' % self.stage.source_path, '-I%s' % self.stage.source_path,
'-I%s' % spec['garply'].prefix.include, '-I%s' % spec['garply'].prefix.include,
@ -110,18 +112,36 @@ class Quux
'-O2', '-g', '-DNDEBUG', '-fPIC', '-O2', '-g', '-DNDEBUG', '-fPIC',
'-o', 'quuxifier.cc.o', '-o', 'quuxifier.cc.o',
'-c', 'quux/quuxifier.cc') '-c', 'quux/quuxifier.cc')
gpp('-fPIC', '-O2', '-g', '-DNDEBUG', '-shared', if sys.platform == 'darwin':
'-Wl,-soname,libquux.so', '-o', 'libquux.so', 'quux.cc.o', gpp('-fPIC', '-O2', '-g', '-DNDEBUG',
'-Wl,-rpath,%s:%s::::' % (prefix.lib64, '-dynamiclib', '-Wl,-headerpad_max_install_names',
spec['garply'].prefix.lib64), '-o', 'libquux.dylib',
'%s/libgarply.so' % spec['garply'].prefix.lib64) '-install_name', '@rpath/libcorge.dylib',
gpp('-O2', '-g', '-DNDEBUG', '-rdynamic', 'quux.cc.o', '-Wl,-rpath,%s' % prefix.lib64,
'quuxifier.cc.o', '-o', 'quuxifier', '-Wl,-rpath,%s' % spec['garply'].prefix.lib64,
'-Wl,-rpath,%s:%s::::' % (prefix.lib64, '%s/libgarply.dylib' % spec['garply'].prefix.lib64)
spec['garply'].prefix.lib64), gpp('-O2', '-g', '-DNDEBUG',
'libquux.so', 'quuxifier.cc.o', '-o', 'quuxifier',
'%s/libgarply.so' % spec['garply'].prefix.lib64) '-Wl,-rpath,%s' % prefix.lib64,
copy('libquux.so', '%s/libquux.so' % prefix.lib64) '-Wl,-rpath,%s' % spec['garply'].prefix.lib64,
'libquux.dylib',
'%s/libgarply.dylib' % spec['garply'].prefix.lib64)
mkdirp(prefix.lib64)
copy('libquux.dylib', '%s/libquux.dylib' % prefix.lib64)
else:
gpp('-fPIC', '-O2', '-g', '-DNDEBUG', '-shared',
'-Wl,-soname,libquux.so', '-o', 'libquux.so', 'quux.cc.o',
'-Wl,-rpath,%s:%s::::' % (prefix.lib64,
spec['garply'].prefix.lib64),
'%s/libgarply.so' % spec['garply'].prefix.lib64)
gpp('-O2', '-g', '-DNDEBUG', '-rdynamic',
'quuxifier.cc.o', '-o', 'quuxifier',
'-Wl,-rpath,%s:%s::::' % (prefix.lib64,
spec['garply'].prefix.lib64),
'libquux.so',
'%s/libgarply.so' % spec['garply'].prefix.lib64)
mkdirp(prefix.lib64)
copy('libquux.so', '%s/libquux.so' % prefix.lib64)
copy('quuxifier', '%s/quuxifier' % prefix.lib64) copy('quuxifier', '%s/quuxifier' % prefix.lib64)
copy('%s/quux/quux.h' % self.stage.source_path, copy('%s/quux/quux.h' % self.stage.source_path,
'%s/quux/quux.h' % prefix.include) '%s/quux/quux.h' % prefix.include)