diff --git a/easybuild/framework/easyblock.py b/easybuild/framework/easyblock.py index e92bc87450..a6e67eccf1 100644 --- a/easybuild/framework/easyblock.py +++ b/easybuild/framework/easyblock.py @@ -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 @@ -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'] +LIB_STATIC_SUFFIX = 'a' +LIB_SHARED_SUFFIX = get_shared_lib_ext() + _log = fancylogger.getLogger('easyblock') @@ -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()] diff --git a/test/framework/easyblock.py b/test/framework/easyblock.py index cb34331de3..877a464948 100644 --- a/test/framework/easyblock.py +++ b/test/framework/easyblock.py @@ -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 @@ -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')