mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
Added libstringstream, which maps stdin and stdout to std::iostream. Using this library means we no longer create either the temporary .py file or the ct2ctml.log file. This also eliminates the synchronization problems that motivated the sleep commands around the system call, so cti to ctml conversions are significantly faster now.
109 lines
3.5 KiB
Python
109 lines
3.5 KiB
Python
from buildutils import *
|
|
|
|
Import('env', 'build', 'install', 'libraryTargets')
|
|
localenv = env.Clone()
|
|
|
|
def prep_default(env):
|
|
return env.Clone()
|
|
|
|
def prep_fortran(env):
|
|
localenv = env.Clone()
|
|
localenv.Append(CPPPATH='#include/cantera/base') # for config.h
|
|
return localenv
|
|
|
|
def prep_f2c(env):
|
|
localenv = env.Clone()
|
|
|
|
localenv.Append(CPPPATH=Dir('#ext/f2c_libs'))
|
|
if not localenv['HAS_TIMES_H']:
|
|
localenv.Append(CPPDEFINES=['USE_CLOCK'])
|
|
if not localenv['HAS_UNISTD_H']:
|
|
localenv.Append(CPPDEFINES=['MSDOS'])
|
|
|
|
# The F2C code generates a lot of warnings designed to catch
|
|
# programmer errors, but since this is autogenerated code, those
|
|
# warnings are irrelevant.
|
|
if '-Wall' in localenv['CCFLAGS']:
|
|
localenv['CCFLAGS'].remove('-Wall')
|
|
localenv['CCFLAGS'].append('-Wno-format-security')
|
|
elif '/W3' in localenv['CCFLAGS']:
|
|
localenv['CCFLAGS'].remove('/W3')
|
|
elif '-Wcheck' in localenv['CCFLAGS']:
|
|
localenv['CCFLAGS'].remove('-Wcheck')
|
|
if localenv['CC'] == 'clang':
|
|
localenv['CCFLAGS'].append('-w')
|
|
|
|
return localenv
|
|
|
|
def prep_sundials(env):
|
|
localenv = env.Clone()
|
|
localenv.Append(CPPPATH=Dir('#ext/cvode/include'))
|
|
|
|
# Suppress warnings from external code
|
|
if '-Wall' in localenv['CCFLAGS']:
|
|
localenv['CCFLAGS'].append('-Wno-format')
|
|
|
|
return localenv
|
|
|
|
def prep_gtest(env):
|
|
localenv = env.Clone()
|
|
localenv.Append(CPPPATH=[Dir('#ext/gtest'),
|
|
Dir('#ext/gtest/include')],
|
|
CPPDEFINES={'GTEST_HAS_PTHREAD': 0})
|
|
return localenv
|
|
|
|
# (subdir, (file extensions), prepfunction)
|
|
libs = [('libexecstream', ['cpp'], prep_default)]
|
|
|
|
if env['build_with_f2c']:
|
|
libs.append(('f2c_math', ['cpp','c'], prep_f2c))
|
|
|
|
# Create arith.h using the arithchk program
|
|
if not os.path.exists('arith.h'):
|
|
arithenv = prep_f2c(env)
|
|
|
|
# TODO: make link flag more general
|
|
arithenv.Append(CPPFLAGS='-DNO_FPINIT')
|
|
arithenv.Program('f2c_libs/arithchk/arithchk', source='f2c_libs/arithchk/arithchk.c',
|
|
LIBS=env['LIBM'])
|
|
arithenv.Command('#ext/f2c_libs/arith.h', 'f2c_libs/arithchk/arithchk$PROGSUFFIX',
|
|
'$SOURCE > $TARGET')
|
|
|
|
headerenv = prep_f2c(env)
|
|
# Possibly system-depenent headers
|
|
headerenv.Command('#ext/f2c_libs/signal1.h', 'f2c_libs/signal1.h0',
|
|
Copy('$TARGET', '$SOURCE'))
|
|
|
|
headerenv.Command('#ext/f2c_libs/sysdep1.h', 'f2c_libs/sysdep1.h0',
|
|
Copy('$TARGET', '$SOURCE'))
|
|
|
|
libs.append(('f2c_libs', 'c', prep_f2c))
|
|
|
|
if env['BUILD_BLAS_LAPACK']:
|
|
libs.append(('f2c_blas', ['c'], prep_f2c))
|
|
libs.append(('f2c_lapack', ['c'], prep_f2c))
|
|
|
|
else:
|
|
libs.append(('math', ['cpp','c','f'], prep_fortran))
|
|
|
|
if env['BUILD_BLAS_LAPACK']:
|
|
libs.append(('blas', ['f'], prep_default))
|
|
libs.append(('lapack', ['f'], prep_default))
|
|
|
|
if env['use_sundials'] == 'n':
|
|
libs.append(('cvode/source', ['c'], prep_sundials))
|
|
|
|
|
|
for subdir, extensions, prepFunction in libs:
|
|
localenv = prepFunction(env)
|
|
objects = localenv.SharedObject(mglob(localenv, subdir, *extensions))
|
|
libraryTargets.extend(objects)
|
|
|
|
# Google Teset
|
|
localenv = env.Clone()
|
|
localenv.Append(CPPPATH=[Dir('#ext/gtest'),
|
|
Dir('#ext/gtest/include')],
|
|
CPPDEFINES={'GTEST_HAS_PTHREAD': 0})
|
|
build(localenv.Library(pjoin('../lib', 'gtest'),
|
|
source=['gtest/src/gtest-all.cc']))
|