diff --git a/python/SConscript b/python/SConscript index 4a705c9..1f89693 100644 --- a/python/SConscript +++ b/python/SConscript @@ -1,48 +1,48 @@ from __future__ import print_function import SCons from os.path import abspath, join from SCons.Script import Import, Depends, Split, Copy Import('main_env') # Pybind11 wrapper env_pybind = main_env.Clone(SHLIBPREFIX='') env_pybind.Tool(pybind11) pybind_sources = Split(""" tamaas_module.cpp wrap/core.cpp wrap/percolation.cpp wrap/surface.cpp wrap/model.cpp wrap/solvers.cpp wrap/test_features.cpp """) if main_env['CXX'] != 'icpc': pybind_sources += ["wrap/bem.cpp"] env_pybind.AppendUnique(CPPDEFINES="LEGACY_BEM") # Building the pybind library tamaas_wrap = env_pybind.SharedLibrary( target='tamaas/_tamaas', source=pybind_sources, LIBS=['Tamaas'], RPATH=[abspath('../src')] ) # For some reason link happens too early Import('libTamaas') -Depends(tamaas_wrap, libTamaas) +env_pybind.Depends(tamaas_wrap, libTamaas) # Copying the __init__.py file with extra python classes copy_env = env_pybind.Clone( PRINT_CMD_LINE_FUNC=main_env['gen_print']("Copying", "red", main_env)) copy_env.Command(Dir('tamaas'), Dir('#python/tamaas'), Copy("$TARGET", "$SOURCE")) copy_env.Command('setup.py', '#python/setup.py', Copy("$TARGET", "$SOURCE")) # Cleaning the tamaas python package main_env.Execute(Delete('tamaas')) diff --git a/tests/SConscript b/tests/SConscript index 218a82f..2ac7783 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -1,134 +1,140 @@ from __future__ import print_function from os.path import join, abspath from SCons.Script import Split, Copy, Dir, Import from detect import FindGTest # ------------------------------------------------------------------------------ def copyComStr(env, main): if 'SHCXXCOMSTR' in main: env['CXXCOMSTR'] = main['SHCXXCOMSTR'] if 'SHLINKCOMSTR' in main: env['LINKCOMSTR'] = main['SHLINKCOMSTR'] # ------------------------------------------------------------------------------ def make_python_tests(env): """Copy python tests to build directory""" test_env = env.Clone( PRINT_CMD_LINE_FUNC=main_env['gen_print']("Copying", "red", main_env)) test_files = Split(""" run_tests.sh test_hertz.py test_westergaard.py test_patch_westergaard.py test_surface.py test_autocorrelation.py test_hertz_disp.py test_hertz_kato.py test_saturated_pressure.py test_bem_grid.py test_flood_fill.py test_integral_operators.py test_dumper.py test_gtest.py test_tangential.py test_boussinesq_surface.py test_voigt.py fftfreq.py conftest.py """) src_dir = "#/tests" build_dir = 'build-' + main_env['build_type'] + '/tests' for file in test_files: source = join(src_dir, file) test_env.Command(file, source, Copy("$TARGET", "$SOURCE")) + test_env = env.Clone() # Helper module for integral operators test_env['SHLIBPREFIX'] = '' - test_env.SharedLibrary(target="register_integral_operators", - source=["register_integral_operators.cpp"], - LIBS=['Tamaas'], - RPATH=[abspath('../src')]) + register = test_env.SharedLibrary(target="register_integral_operators", + source=["register_integral_operators.cpp"], + LIBS=['Tamaas'], + RPATH=[abspath('../src')]) + Import('libTamaas') + test_env.Depends(register, libTamaas) # ------------------------------------------------------------------------------ def compile_google_test(env, gtest_path): gtest_obj = env.Object('gtest.o', [join(gtest_path, "src/gtest-all.cc")]) - env.StaticLibrary('gtest', gtest_obj) + return env.StaticLibrary('gtest', gtest_obj) # ------------------------------------------------------------------------------ def make_google_tests(env): gtest_dir = Dir(env['GTEST_ROOT']) gtest_env = env.Clone(CPPPATH=[gtest_dir], CXXFLAGS=['-pthread', '-isystem', join(str(gtest_dir), "include")]) colors = env['COLOR_DICT'] if not env['verbose']: gtest_env['ARCOMSTR'] = u'{}[Ar]{} $TARGET'.format(colors['purple'], colors['end']) gtest_env['RANLIBCOMSTR'] = \ u'{}[Randlib]{} $TARGET'.format(colors['purple'], colors['end']) FindGTest(gtest_env) + libgtest = None # Hugly hack to detect if we need to compile gtest submodule if env['GTEST_ROOT'] == '#third-party/googletest/googletest': gtest_path = str(gtest_dir) - compile_google_test(gtest_env, gtest_path) + libgtest = compile_google_test(gtest_env, gtest_path) env.AppendUnique(LIBS=['Tamaas'], CXXFLAGS=gtest_env['CXXFLAGS']) google_test_files = Split(""" test_fft.cpp test_grid.cpp test_loop.cpp test_model.cpp test_static_types.cpp test_integration.cpp """) gtest_main = env.Object("tamaas_gtest_main.o", 'tamaas_gtest_main.cc') - env.Program('test_gtest_all', google_test_files + [gtest_main], - LIBS=(env['LIBS'] + ['gtest'])) + gtest_all = env.Program('test_gtest_all', google_test_files + [gtest_main], + LIBS=(env['LIBS'] + ['gtest'])) + Import('libTamaas') + env.Depends(gtest_all, libTamaas) + env.Depends(gtest_all, libgtest) # ------------------------------------------------------------------------------ def make_bare_tests(env): env.Program("test_rough_surface.cpp") # ------------------------------------------------------------------------------ Import('main_env') # Setup of test environment test_env = main_env.Clone() test_env.AppendUnique(LIBS=['Tamaas'], LIBPATH=[abspath('build-' + main_env['build_type'] + '/src')]) copyComStr(test_env, main_env) # Building tests that do not require any third party make_bare_tests(test_env) if test_env['build_python']: test_env.Tool(pybind11) - # test_env.AppendUnique(LIBS=['python3.6m']) test_env.ParseConfig("{}-config --ldflags".format(test_env['py_exec'])) test_env['CCFLAGS'] = [] make_python_tests(test_env) # Building google tests if test_env['use_googletest']: make_google_tests(test_env)