[Test] Use Cantera shared library for tests, when possible
On Linux systems, link tests against the Cantera shared library, rather than the static library to reduce the size of the compiled test suite. This saves over 1 GB of disk space when compiling with debug symbols enabled, and also reduces the run time of the test suite. This does not work on Windows, where the shared library only exports the Cantera C interface.
This commit is contained in:
parent
4544fd3392
commit
1a5f75dd2d
2 changed files with 30 additions and 8 deletions
|
|
@ -5,9 +5,16 @@ from xml.etree import ElementTree
|
||||||
Import('env','build','install')
|
Import('env','build','install')
|
||||||
localenv = env.Clone()
|
localenv = env.Clone()
|
||||||
|
|
||||||
|
# Where possible, link tests against the shared libraries to minimize the sizes
|
||||||
|
# of the resulting binaries.
|
||||||
|
if localenv['OS'] == 'Linux':
|
||||||
|
cantera_libs = localenv['cantera_shared_libs']
|
||||||
|
else:
|
||||||
|
cantera_libs = localenv['cantera_libs']
|
||||||
|
|
||||||
localenv.Prepend(CPPPATH=['#ext/gtest/include', '#include'],
|
localenv.Prepend(CPPPATH=['#ext/gtest/include', '#include'],
|
||||||
LIBPATH='#build/lib')
|
LIBPATH='#build/lib')
|
||||||
localenv.Append(LIBS=['gtest'] + localenv['cantera_libs'],
|
localenv.Append(LIBS=['gtest'] + cantera_libs,
|
||||||
CCFLAGS=env['warning_flags'])
|
CCFLAGS=env['warning_flags'])
|
||||||
|
|
||||||
# Turn of optimization to speed up compilation
|
# Turn of optimization to speed up compilation
|
||||||
|
|
@ -22,9 +29,11 @@ localenv['ENV']['CANTERA_DATA'] = Dir('#build/data').abspath
|
||||||
PASSED_FILES = {}
|
PASSED_FILES = {}
|
||||||
|
|
||||||
# Needed for Intel runtime libraries when compiling with ICC
|
# Needed for Intel runtime libraries when compiling with ICC
|
||||||
if 'LD_LIBRARY_PATH' in os.environ:
|
# Add build/lib in order to find Cantera shared library
|
||||||
localenv['ENV']['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
|
if localenv['ENV'].get('LD_LIBRARY_PATH'):
|
||||||
|
localenv['ENV']['LD_LIBRARY_PATH'] += os.pathsep + Dir('#build/lib').abspath
|
||||||
|
else:
|
||||||
|
localenv['ENV']['LD_LIBRARY_PATH'] = Dir('#build/lib').abspath
|
||||||
|
|
||||||
def addTestProgram(subdir, progName, env_vars={}):
|
def addTestProgram(subdir, progName, env_vars={}):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,13 @@ for optimize_flag in ('-O3', '-O2', '/O2'):
|
||||||
ccflags.remove(optimize_flag)
|
ccflags.remove(optimize_flag)
|
||||||
localenv['CCFLAGS'] = ccflags
|
localenv['CCFLAGS'] = ccflags
|
||||||
|
|
||||||
|
# Where possible, link tests against the shared libraries to minimize the sizes
|
||||||
|
# of the resulting binaries.
|
||||||
|
if localenv['OS'] == 'Linux':
|
||||||
|
cantera_libs = localenv['cantera_shared_libs']
|
||||||
|
else:
|
||||||
|
cantera_libs = localenv['cantera_libs']
|
||||||
|
|
||||||
if localenv['python_package'] in ('full', 'minimal'):
|
if localenv['python_package'] in ('full', 'minimal'):
|
||||||
localenv['ENV']['PYTHONPATH'] = localenv['pythonpath_build2']
|
localenv['ENV']['PYTHONPATH'] = localenv['pythonpath_build2']
|
||||||
localenv['ENV']['PYTHON_CMD'] = localenv.subst('$python_cmd')
|
localenv['ENV']['PYTHON_CMD'] = localenv.subst('$python_cmd')
|
||||||
|
|
@ -25,6 +32,12 @@ else:
|
||||||
|
|
||||||
localenv['ENV']['CANTERA_DATA'] = pjoin(os.getcwd(), '..', 'build', 'data')
|
localenv['ENV']['CANTERA_DATA'] = pjoin(os.getcwd(), '..', 'build', 'data')
|
||||||
|
|
||||||
|
# Add build/lib in order to find Cantera shared library
|
||||||
|
if localenv['ENV'].get('LD_LIBRARY_PATH'):
|
||||||
|
localenv['ENV']['LD_LIBRARY_PATH'] += os.pathsep + Dir('#build/lib').abspath
|
||||||
|
else:
|
||||||
|
localenv['ENV']['LD_LIBRARY_PATH'] = Dir('#build/lib').abspath
|
||||||
|
|
||||||
PASSED_FILES = {}
|
PASSED_FILES = {}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -122,7 +135,7 @@ class CompileAndTest(Test):
|
||||||
def run(self, env):
|
def run(self, env):
|
||||||
prog = env.Program(pjoin(self.subdir, self.programName),
|
prog = env.Program(pjoin(self.subdir, self.programName),
|
||||||
mglob(env, self.subdir, *self.extensions),
|
mglob(env, self.subdir, *self.extensions),
|
||||||
LIBS=env['cantera_libs'])
|
LIBS=cantera_libs)
|
||||||
source = [prog]
|
source = [prog]
|
||||||
return Test.run(self, env, *source)
|
return Test.run(self, env, *source)
|
||||||
|
|
||||||
|
|
@ -135,7 +148,7 @@ class CompileAndTest(Test):
|
||||||
|
|
||||||
dhGraph = localenv.Program('cathermo/DH_graph_1/DH_graph_1',
|
dhGraph = localenv.Program('cathermo/DH_graph_1/DH_graph_1',
|
||||||
mglob(env, 'cathermo/DH_graph_1', 'cpp'),
|
mglob(env, 'cathermo/DH_graph_1', 'cpp'),
|
||||||
LIBS=env['cantera_libs'])
|
LIBS=cantera_libs)
|
||||||
dhGraph_name = dhGraph[0].name
|
dhGraph_name = dhGraph[0].name
|
||||||
|
|
||||||
Test('DH_graph_dilute',
|
Test('DH_graph_dilute',
|
||||||
|
|
@ -255,7 +268,7 @@ CompileAndTest('cxx_ex', 'cxx_ex', 'cxx_examples', 'output_blessed.txt',
|
||||||
|
|
||||||
diamond = localenv.Program('diamondSurf/runDiamond',
|
diamond = localenv.Program('diamondSurf/runDiamond',
|
||||||
'diamondSurf/runDiamond.cpp',
|
'diamondSurf/runDiamond.cpp',
|
||||||
LIBS=env['cantera_libs'])
|
LIBS=cantera_libs)
|
||||||
diamond_name = diamond[0].name
|
diamond_name = diamond[0].name
|
||||||
Test('diamondSurf-xml', 'diamondSurf', diamond, 'runDiamond_blessed.out',
|
Test('diamondSurf-xml', 'diamondSurf', diamond, 'runDiamond_blessed.out',
|
||||||
options='diamond_blessed.xml', artifacts=diamond_name)
|
options='diamond_blessed.xml', artifacts=diamond_name)
|
||||||
|
|
@ -271,7 +284,7 @@ CompileAndTest('multiGasTransport',
|
||||||
|
|
||||||
negA = localenv.Program('negATest/negATest',
|
negA = localenv.Program('negATest/negATest',
|
||||||
mglob(env, 'negATest', 'cpp'),
|
mglob(env, 'negATest', 'cpp'),
|
||||||
LIBS=env['cantera_libs'])
|
LIBS=cantera_libs)
|
||||||
negA_name = negA[0].name
|
negA_name = negA[0].name
|
||||||
Test('negA-xml', 'negATest', negA, 'negATest_blessed.out',
|
Test('negA-xml', 'negATest', negA, 'negATest_blessed.out',
|
||||||
options='noxNeg_blessed.xml', artifacts=negA_name)
|
options='noxNeg_blessed.xml', artifacts=negA_name)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue