Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F68346532
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
Thu, Jun 27, 00:04
Size
5 KB
Mime Type
text/x-python
Expires
Sat, Jun 29, 00:04 (2 d)
Engine
blob
Format
Raw Data
Handle
18568086
Attached To
rTAMAAS tamaas
SConscript
View Options
# -*- coding: utf-8 -*-
# @file
# @section LICENSE
#
# Copyright (©) 2016-19 EPFL (École Polytechnique Fédérale de Lausanne),
# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
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
test_memory.py
fftfreq.py
conftest.py
""")
src_dir = "#/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'] = ''
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")])
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)
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')
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):
rough = env.Program("test_rough_surface.cpp")
Import('libTamaas')
env.Depends(rough, libTamaas)
# ------------------------------------------------------------------------------
Import('main_env')
# Setup of test environment
test_env = main_env.Clone()
test_env.AppendUnique(LIBS=['Tamaas'], LIBPATH=['.'])
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.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