SCons now builds the Matlab toolbox

This commit is contained in:
Ray Speth 2011-12-14 03:52:01 +00:00
parent 53cfa84670
commit 947d8260ad
2 changed files with 54 additions and 1 deletions

50
Cantera/matlab/SConscript Normal file
View file

@ -0,0 +1,50 @@
from buildutils import *
Import('env', 'build')
class MatlabBuilder(object):
def __init__(self, libs):
self.libs = libs
def __call__(self, target, source, env):
filenames = [os.path.split(node.path)[1] for node in source]
sourcestr = ' '.join(pjoin('private',name) for name in filenames)
includes = ' '.join('-I%s' % Dir(s).abspath for s in env['CPPPATH'])
libdir = ' '.join('-L%s' % Dir(s).abspath for s in env['LIBPATH'])
libs = ' '.join('-l'+s for s in self.libs)
text = """
disp('building Cantera...');
mex -cxx -v %(sourcestr)s %(include)s %(libdir)s %(libs)s
disp('done.');
exit
""" % dict(sourcestr=sourcestr,
include=includes,
libdir=libdir,
libs=libs)
with open(str(target[0]), 'w') as f:
f.write(text)
localenv = env.Clone()
linkLibs = ['clib','oneD','zeroD','equil','kinetics','transport',
'thermo','ctnumerics','ctmath','tpx',
'ctspectra','converters','ctbase']
if env['use_sundials']:
linkLibs.extend(('sundials_cvodes','sundials_nvecserial'))
linkLibs.extend(localenv['blas_lapack_libs'])
if env['build_with_f2c']:
linkLibs.append('ctf2c')
else:
linkLibs.append('gfortran')
localenv.Command('cantera/build_cantera.m', mglob(localenv, 'cantera/private', 'cpp'),
MatlabBuilder(linkLibs))
localenv['ENV']['PATH'] = os.environ['PATH']
localenv.Command('cantera/ctfunctions.mexa64', 'cantera/build_cantera.m',
'cd ${SOURCE.dir}; %(matlab_cmd)s -nojvm -nosplash -r build_cantera' % localenv)

View file

@ -103,7 +103,7 @@ else:
if env['matlab_toolbox'] != 'n':
opts.AddVariables(
PathVariable('matlab_cmd', 'Path to the matlab executable',
'default', PathVariable.PathAccept)
'matlab', PathVariable.PathAccept)
)
# Options that apply only if building the Fortran interface
@ -271,3 +271,6 @@ VariantDir('build/interfaces/fortran/', 'Cantera/fortran', duplicate=1)
SConscript('build/interfaces/fortran/SConscript')
SConscript('Cantera/python/SConscript')
if env['matlab_toolbox'] == 'y':
SConscript('Cantera/matlab/SConscript')