Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion easybuild/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
from easybuild.tools.package.utilities import package
from easybuild.tools.repository.repository import init_repository
from easybuild.tools.toolchain import DUMMY_TOOLCHAIN_NAME
from easybuild.tools.systemtools import det_parallelism, use_group
from easybuild.tools.systemtools import det_parallelism, get_shared_lib_ext, use_group
from easybuild.tools.utilities import remove_unwanted_chars
from easybuild.tools.version import this_is_easybuild, VERBOSE_VERSION, VERSION

Expand All @@ -100,6 +100,11 @@

MODULE_ONLY_STEPS = [MODULE_STEP, PREPARE_STEP, READY_STEP, SANITYCHECK_STEP]

# constants for library checking (TODO: should probably be configurable)
LIB_DIRS = ['lib', 'lib64']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, making this configurable makes a lot of sense.

LIB_STATIC_SUFFIX = 'a'
LIB_SHARED_SUFFIX = get_shared_lib_ext()


_log = fancylogger.getLogger('easyblock')

Expand Down Expand Up @@ -1688,6 +1693,20 @@ def _sanity_check_step_common(self, custom_paths, custom_commands):
else:
self.log.info("Using specified sanity check paths: %s" % paths)

def gen_library_paths(name, suffix):
"""little helper function to generate tuple of paths of a single library and given suffix"""
libpaths = []
for dir in LIB_DIRS:
libpaths.append(os.path.join(dir, "%s.%s" % (name, suffix)))
return tuple(libpaths)

# transform specified libs into simple file paths
for lib in paths.pop('shared_libs', []):
paths['files'].append(gen_library_paths(lib, LIB_SHARED_SUFFIX))
for lib in paths.pop('static_libs', []):
paths['files'].append(gen_library_paths(lib, LIB_STATIC_SUFFIX))

# check sanity check paths
ks = sorted(paths.keys())
valnottypes = [not isinstance(x, list) for x in paths.values()]
lenvals = [len(x) for x in paths.values()]
Expand Down
26 changes: 26 additions & 0 deletions test/framework/easyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
from easybuild.tools.build_log import EasyBuildError
from easybuild.tools.config import get_module_syntax
from easybuild.tools.filetools import mkdir, read_file, write_file
from easybuild.tools.systemtools import get_shared_lib_ext
from easybuild.tools.modules import modules_tool


Expand Down Expand Up @@ -647,6 +648,31 @@ def test_patch_step(self):
self.assertTrue("and very proud of it" in read_file(os.path.join(toydir, 'toy.source')))
self.assertEqual(read_file(os.path.join(toydir, 'toy-extra.txt')), 'moar!\n')

def test_sanity_check_paths_for_libraries(self):
"""Test generation of sanity check paths for libraries."""
test_easyconfigs = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'easyconfigs')
ec = process_easyconfig(os.path.join(test_easyconfigs, 'toy-0.0.eb'))[0]
# specify that libtoy.a and libtoy.so should also be there, either in lib or lib64
ec['ec']['sanity_check_paths'].update({
'shared_libs': ['libtoy'],
'static_libs': ['libtoy'],
})

from easybuild.easyblocks.toy import EB_toy
eb = EB_toy(ec['ec'])
eb.fetch_step()
eb.extract_step()
eb.configure_step()
eb.build_step()
eb.install_step()

libdir = os.path.join(eb.installdir, 'lib')
mkdir(libdir)
write_file(os.path.join(libdir, 'libtoy.%s' % get_shared_lib_ext()), 'shared lib')
write_file(os.path.join(libdir, 'libtoy.a'), 'static lib')

eb.sanity_check_step()

def test_extensions_sanity_check(self):
"""Test sanity check aspect of extensions."""
test_ecs_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'easyconfigs')
Expand Down