2011-12-14 02:41:29 +00:00
|
|
|
from buildutils import *
|
|
|
|
|
|
2012-03-05 20:45:20 +00:00
|
|
|
Import('env', 'build', 'install', 'libraryTargets')
|
2011-12-14 02:41:29 +00:00
|
|
|
localenv = env.Clone()
|
2018-02-12 22:59:43 -05:00
|
|
|
copyenv = localenv.Clone() # no CPPPATH addition, to avoid circular dependencies
|
2011-12-14 02:41:29 +00:00
|
|
|
|
2016-06-24 15:51:44 -04:00
|
|
|
license_files = [('Cantera', '#License.txt'),
|
|
|
|
|
('Libexecstream', 'libexecstream/doc/license.txt')]
|
2016-06-24 13:34:27 -04:00
|
|
|
|
2012-01-17 23:58:33 +00:00
|
|
|
def prep_default(env):
|
2014-02-21 19:08:54 +00:00
|
|
|
localenv = env.Clone()
|
|
|
|
|
|
|
|
|
|
# Suppress warnings from external code and auto-generated code
|
2014-02-24 03:25:15 +00:00
|
|
|
if 'g++' in localenv['CXX'] or 'clang' in localenv['CXX']:
|
|
|
|
|
localenv.Append(CCFLAGS='-w')
|
2014-02-21 19:08:54 +00:00
|
|
|
|
|
|
|
|
return localenv
|
2011-12-14 02:41:29 +00:00
|
|
|
|
2013-02-01 23:39:53 +00:00
|
|
|
|
2012-02-01 23:34:40 +00:00
|
|
|
def prep_gtest(env):
|
2014-02-21 19:08:54 +00:00
|
|
|
localenv = prep_default(env)
|
2017-10-19 00:11:32 -04:00
|
|
|
localenv.Prepend(CPPPATH=[Dir('#ext/googletest/googletest'),
|
|
|
|
|
Dir('#ext/googletest/googletest/include')],
|
|
|
|
|
CPPDEFINES={'GTEST_HAS_PTHREAD': 0})
|
2012-02-01 23:34:40 +00:00
|
|
|
return localenv
|
|
|
|
|
|
2017-10-19 00:11:32 -04:00
|
|
|
|
|
|
|
|
def prep_gmock(env):
|
|
|
|
|
localenv = prep_default(env)
|
|
|
|
|
localenv.Prepend(CPPPATH=[Dir('#ext/googletest/googletest/include'),
|
|
|
|
|
Dir('#ext/googletest/googlemock'),
|
|
|
|
|
Dir('#ext/googletest/googlemock/include')],
|
|
|
|
|
CPPDEFINES={'GTEST_HAS_PTHREAD': 0})
|
|
|
|
|
return localenv
|
|
|
|
|
|
|
|
|
|
|
2015-06-13 23:29:58 -04:00
|
|
|
# each element of libs is: (subdir, (file extensions), prepfunction)
|
2018-05-28 13:12:24 -04:00
|
|
|
libs = [('libexecstream', ['cpp'], prep_default)]
|
|
|
|
|
|
2012-02-13 17:24:34 +00:00
|
|
|
for subdir, extensions, prepFunction in libs:
|
2012-01-17 23:58:33 +00:00
|
|
|
localenv = prepFunction(env)
|
2015-05-11 16:46:49 -04:00
|
|
|
objects = localenv.SharedObject(mglob(localenv, subdir, *extensions))
|
|
|
|
|
libraryTargets.extend(objects)
|
2013-02-15 17:32:31 +00:00
|
|
|
|
2018-05-29 20:47:47 -04:00
|
|
|
if not env['system_fmt']:
|
|
|
|
|
license_files.append(('fmtlib', 'fmt/LICENSE.rst'))
|
2018-05-30 10:28:07 -04:00
|
|
|
for name in ('format.h', 'ostream.h', 'printf.h', 'core.h', 'format-inl.h'):
|
2018-05-29 20:47:47 -04:00
|
|
|
build(copyenv.Command("#include/cantera/ext/fmt/" + name,
|
|
|
|
|
"#ext/fmt/include/fmt/" + name,
|
|
|
|
|
Copy('$TARGET', '$SOURCE')))
|
|
|
|
|
|
2015-11-13 14:55:53 -05:00
|
|
|
if env['system_sundials'] == 'n':
|
|
|
|
|
localenv = prep_default(env)
|
2020-05-22 20:59:44 -04:00
|
|
|
localenv.Prepend(CPPPATH=[Dir('#include/cantera/ext'),
|
|
|
|
|
Dir('#ext/sundials/src/sundials')])
|
2016-06-24 13:34:27 -04:00
|
|
|
license_files.append(('Sundials', 'sundials/LICENSE'))
|
2015-11-13 14:55:53 -05:00
|
|
|
|
|
|
|
|
# Generate sundials_config.h
|
|
|
|
|
sundials_configh = {}
|
|
|
|
|
if env['OS'] != 'Windows':
|
|
|
|
|
sundials_configh['SUNDIALS_USE_GENERIC_MATH'] = 1
|
2016-04-13 18:24:49 -04:00
|
|
|
if env['use_lapack']:
|
2015-11-13 14:55:53 -05:00
|
|
|
sundials_configh['SUNDIALS_BLAS_LAPACK'] = 1
|
|
|
|
|
localenv.AlwaysBuild(env.Command('#include/cantera/ext/sundials/sundials_config.h',
|
|
|
|
|
'sundials_config.h.in',
|
|
|
|
|
ConfigBuilder(sundials_configh)))
|
|
|
|
|
|
|
|
|
|
# Copy sundials header files into common include directory
|
2019-12-17 23:33:49 -05:00
|
|
|
for subdir in ('sundials', 'nvector', 'cvodes', 'ida', 'sunmatrix',
|
|
|
|
|
'sunlinsol', 'sunnonlinsol'):
|
2015-11-13 14:55:53 -05:00
|
|
|
for header in mglob(env, 'sundials/include/'+subdir, 'h'):
|
2018-02-12 22:59:43 -05:00
|
|
|
build(copyenv.Command('#include/cantera/ext/%s/%s' % (subdir, header.name),
|
|
|
|
|
'#ext/sundials/include/%s/%s' % (subdir, header.name),
|
|
|
|
|
Copy('$TARGET', '$SOURCE')))
|
2015-11-13 14:55:53 -05:00
|
|
|
|
|
|
|
|
# Compile Sundials source files
|
2019-12-17 23:33:49 -05:00
|
|
|
subdirs = ['sundials', 'nvector/serial', 'cvodes', 'ida', 'sunmatrix/band',
|
|
|
|
|
'sunmatrix/dense', 'sunmatrix/sparse', 'sunlinsol/dense',
|
|
|
|
|
'sunlinsol/band','sunlinsol/spgmr', 'sunnonlinsol/newton']
|
2018-02-12 23:02:47 -05:00
|
|
|
if env['use_lapack']:
|
2019-12-17 23:33:49 -05:00
|
|
|
subdirs.extend(('sunlinsol/lapackdense', 'sunlinsol/lapackband'))
|
2018-02-12 23:02:47 -05:00
|
|
|
|
|
|
|
|
for subdir in subdirs:
|
2015-11-13 14:55:53 -05:00
|
|
|
libraryTargets.extend(localenv.SharedObject(
|
2018-02-12 23:02:47 -05:00
|
|
|
[f for f in mglob(localenv, 'sundials/src/'+subdir, 'c')]))
|
2015-11-13 14:55:53 -05:00
|
|
|
|
2018-01-11 21:42:25 -05:00
|
|
|
if not env['system_yamlcpp']:
|
|
|
|
|
localenv = prep_default(env)
|
|
|
|
|
localenv.Prepend(CPPPATH=Dir('#include/cantera/ext'))
|
|
|
|
|
license_files.append(('YAML-CPP', 'yaml-cpp/LICENSE'))
|
|
|
|
|
|
|
|
|
|
# Copy header files into common include directory
|
|
|
|
|
for subdir in ('', 'contrib', 'node', 'node/detail'):
|
|
|
|
|
for header in mglob(env, 'yaml-cpp/include/yaml-cpp/'+subdir, 'h'):
|
|
|
|
|
h = build(localenv.Command('#include/cantera/ext/yaml-cpp/{}/{}'.format(subdir, header.name),
|
|
|
|
|
'#ext/yaml-cpp/include/yaml-cpp/{}/{}'.format(subdir, header.name),
|
|
|
|
|
Copy('$TARGET', '$SOURCE')))
|
|
|
|
|
|
|
|
|
|
# Compile yaml-cpp source files
|
|
|
|
|
for subdir in ('', 'contrib'):
|
|
|
|
|
libraryTargets.extend(localenv.SharedObject(
|
|
|
|
|
[f for f in mglob(localenv, 'yaml-cpp/src/'+subdir, 'cpp')]))
|
|
|
|
|
|
|
|
|
|
|
2016-04-09 22:31:40 -04:00
|
|
|
if not env['system_eigen']:
|
2016-06-24 13:34:27 -04:00
|
|
|
license_files.append(('Eigen', 'eigen/COPYING.MPL2'))
|
2019-01-30 14:20:12 -05:00
|
|
|
h = build(copyenv.Command('#include/cantera/ext/Eigen', '#ext/eigen/Eigen',
|
|
|
|
|
Copy('$TARGET', '$SOURCE')))
|
|
|
|
|
copyenv.Depends(copyenv['config_h_target'], h)
|
2016-04-09 22:31:40 -04:00
|
|
|
|
2015-06-13 23:29:58 -04:00
|
|
|
# Google Test: Used internally for Cantera unit tests.
|
2018-07-06 17:16:05 -04:00
|
|
|
if env['googletest'] == 'submodule':
|
2015-10-17 23:52:04 -04:00
|
|
|
localenv = prep_gtest(env)
|
|
|
|
|
gtest = build(localenv.Library('../lib/gtest',
|
2017-10-19 00:11:32 -04:00
|
|
|
source=['googletest/googletest/src/gtest-all.cc']))
|
|
|
|
|
localenv = prep_gmock(env)
|
|
|
|
|
gmock = build(localenv.Library('../lib/gmock',
|
|
|
|
|
source=['googletest/googlemock/src/gmock-all.cc']))
|
2016-06-24 13:34:27 -04:00
|
|
|
|
|
|
|
|
# Create license file containing licenses for Cantera and all included packages
|
|
|
|
|
def generate_license(target, source, env):
|
|
|
|
|
stars = '*'*50 + '\n' + '*'*50 + '\n'
|
|
|
|
|
tpl = stars + 'The following license applies to {}\n' + stars + '\n{}\n'
|
|
|
|
|
|
|
|
|
|
license = []
|
|
|
|
|
for (package,_),filename in zip(license_files, source):
|
|
|
|
|
license.append(tpl.format(package, open(filename.path).read().strip()))
|
|
|
|
|
|
|
|
|
|
license = '\n'.join(license)
|
|
|
|
|
if target[0].path.endswith('.rtf'):
|
|
|
|
|
license = license.replace('\\', '\\\\').replace('{', '\\{').replace('}', '\\}')
|
|
|
|
|
license = license.replace('\n', ' \\par\n')
|
|
|
|
|
license = r'{\rtf1\ansi{\fonttbl\f0\fswiss Arial;}\f0\pard\fs16 ' + license + '}'
|
|
|
|
|
|
|
|
|
|
open(target[0].path, 'w').write(license)
|
|
|
|
|
|
|
|
|
|
license = build(localenv.Command('LICENSE.txt', [x[1] for x in license_files],
|
|
|
|
|
generate_license))
|
|
|
|
|
install('$inst_docdir', license)
|
|
|
|
|
|
|
|
|
|
if env['OS'] == 'Windows':
|
|
|
|
|
# RTF version is required for Windows installer
|
|
|
|
|
build(localenv.Command('LICENSE.rtf', [x[1] for x in license_files],
|
|
|
|
|
generate_license))
|