Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F66351207
SConscript
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Jun 10, 00:16
Size
4 KB
Mime Type
text/x-python
Expires
Wed, Jun 12, 00:16 (2 d)
Engine
blob
Format
Raw Data
Handle
18208885
Attached To
rTAMAAS tamaas
SConscript
View Options
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
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"))
# 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')])
# ------------------------------------------------------------------------------
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)
# ------------------------------------------------------------------------------
def make_google_tests(env):
gtest_dir = Dir('#/third-party/googletest/googletest')
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)
gtest_path = str(gtest_dir)
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
""")
google_test_files += ['libgtest.a']
gtest_main = env.Object("gtest_main.o", 'tamaas_gtest_main.cc')
env.Program('test_gtest_all', google_test_files + [gtest_main])
# ------------------------------------------------------------------------------
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)
Event Timeline
Log In to Comment