Page MenuHomec4science

SConscript
No OneTemporary

File Metadata

Created
Wed, May 1, 18:18

SConscript

from __future__ import print_function
import os
from os.path import join, abspath, basename
# ------------------------------------------------------------------------------
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_pressure.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
""")
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"))
# ------------------------------------------------------------------------------
def compile_google_test(env, gtest_dir):
gtest_obj = env.Object('gtest.o', [join(gtest_dir, "src/gtest-all.cc")])
env.StaticLibrary('gtest', gtest_obj)
# ------------------------------------------------------------------------------
def make_google_tests(env):
gtest_dir = '#/third-party/googletest/googletest'
gtest_dir = str(Dir(gtest_dir))
# Checking for google test repo
if len(os.listdir(gtest_dir)) == 0:
print("Googletest submodule was not initialized\n" +
"Run 'git submodule update --init --recursive third-party/googletest'")
Exit(1)
gtest_env = env.Clone(CPPPATH=[gtest_dir],
CXXFLAGS=['-pthread', '-isystem',
join(gtest_dir, "include")])
compile_google_test(gtest_env, gtest_dir)
env.AppendUnique(LIBS=['Tamaas'],
CXXFLAGS=gtest_env['CXXFLAGS'])
google_test_files = Split("""
test_fft.cpp
test_grid.cpp
test_loop.cpp
test_model.cpp
""")
google_test_files += ['libgtest.a']
gtest_main = env.Object("gtest_main.o", join(gtest_dir, "src/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)
# Building google tests
if test_env['use_googletest']:
make_google_tests(test_env)

Event Timeline