SCons handles installation of the Matlab toolbox, demos, and examples
This commit is contained in:
parent
f9e8d5ca88
commit
c27078d73a
53 changed files with 99 additions and 147 deletions
|
|
@ -8,13 +8,14 @@ class MatlabBuilder(object):
|
|||
|
||||
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)
|
||||
sourcestr = ' '.join(pjoin('..','src',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
|
||||
cd cantera
|
||||
mex -cxx -v -output ctmethods %(sourcestr)s %(include)s %(libdir)s %(libs)s
|
||||
disp('done.');
|
||||
exit
|
||||
""" % dict(sourcestr=sourcestr,
|
||||
|
|
@ -27,15 +28,24 @@ exit
|
|||
|
||||
localenv = env.Clone()
|
||||
|
||||
localenv.Command('cantera/build_cantera.m',
|
||||
mglob(localenv, 'cantera/private', 'cpp'),
|
||||
localenv.Command('build_cantera.m',
|
||||
mglob(localenv, 'src', 'cpp'),
|
||||
MatlabBuilder(localenv['cantera_libs']))
|
||||
|
||||
localenv['ENV']['PATH'] = os.environ['PATH']
|
||||
|
||||
build_cmd = 'cd ${SOURCE.dir}; %(matlab_cmd)s -nojvm -nosplash -r build_cantera'
|
||||
target = localenv.Command('cantera/ctfunctions.mexa64',
|
||||
'cantera/build_cantera.m',
|
||||
target = localenv.Command('cantera/ctmethods.mexa64',
|
||||
'build_cantera.m',
|
||||
build_cmd % localenv)
|
||||
|
||||
buildTargets.extend(target)
|
||||
|
||||
### Install the Matlab toolbox ###
|
||||
inst = localenv.RecursiveInstall(pjoin('$prefix', 'matlab','toolbox'), 'cantera')
|
||||
installTargets.extend(inst)
|
||||
|
||||
inst = localenv.RecursiveInstall(pjoin('$ct_tutdir', 'matlab'), 'tutorial')
|
||||
installTargets.extend(inst)
|
||||
|
||||
inst = localenv.RecursiveInstall(pjoin('$ct_demodir', 'matlab'), 'examples')
|
||||
installTargets.extend(inst)
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
disp('building Phase...');
|
||||
%buildphase
|
||||
cd @Phase/private
|
||||
mex newphase.cpp -lct
|
||||
mex phase_get.cpp -lct
|
||||
mex phase_set.cpp -lct
|
||||
cd ../..
|
||||
|
||||
disp('building Thermo...');
|
||||
%buildthermo
|
||||
cd @Thermo/private
|
||||
mex newthermo.cpp -lct
|
||||
mex thermo_get.cpp -lct
|
||||
mex thermo_set.cpp -lct
|
||||
cd ../..
|
||||
|
||||
disp('building Kinetics...');
|
||||
%buildkinetics
|
||||
cd @Kinetics/private
|
||||
mex newkinetics.cpp -lct
|
||||
mex kin_get.cpp -lct
|
||||
mex kin_set.cpp -lct
|
||||
mex rstoich.cpp -lct
|
||||
mex pstoich.cpp -lct
|
||||
mex rop.cpp -lct
|
||||
mex production.cpp -lct
|
||||
mex isrev.cpp -lct
|
||||
mex rxnstring.cpp -lct
|
||||
cd ../..
|
||||
|
||||
disp('building Transport...');
|
||||
%buildtransport
|
||||
cd @Transport/private
|
||||
mex newTransport.cpp -lct
|
||||
mex trans_methods.cpp -lct
|
||||
cd ../..
|
||||
|
||||
%
|
||||
disp('building Functions...');
|
||||
cd private
|
||||
mex addCanteraDirectory.cpp -lct
|
||||
mex clearStorage.cpp -lct
|
||||
mex import_from_file.cpp -lct
|
||||
mex getCanteraError.cpp -lct
|
||||
cd ..
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
|
||||
disp('building Cantera as a statically linked mex application ...');
|
||||
mex -v -Ic:/vc_env/cant17/build/include private/ctmethods.cpp private/ctfunctions.cpp ...
|
||||
private/xmlmethods.cpp private/phasemethods.cpp ...
|
||||
private/thermomethods.cpp private/kineticsmethods.cpp ...
|
||||
private/transportmethods.cpp private/reactormethods.cpp ...
|
||||
private/reactornetmethods.cpp ...
|
||||
private/wallmethods.cpp private/flowdevicemethods.cpp ...
|
||||
private/funcmethods.cpp ...
|
||||
private/mixturemethods.cpp ...
|
||||
private/onedimmethods.cpp private/surfmethods.cpp ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/clibstatic.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/oneD.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/zeroD.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/transport.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/equil.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/kinetics.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/thermo.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/numerics.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/converters.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/base.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/ctcxx.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/tpx.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/NVEC_SER.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/CVODES.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/SUNDIALS_SHARED.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/ctmath.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/ctlapack.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/ctblas.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/ctf2c.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/ctlapack.lib ...
|
||||
c:/vc_env/cant17/build/lib/i686-pc-win32/ctblas.lib ...
|
||||
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
function b = importFromFile(th, k, infile, therm_db)
|
||||
%importFromFile import a definition of a phase from a file.
|
||||
%
|
||||
% function importFromFile reads element, species, and reaction
|
||||
% definitions from a file. The elements and species are added to
|
||||
% thermo object 'th', and the reactions are added to 'k', which must be a
|
||||
% kinetics manager for object th.
|
||||
|
||||
if nargin > 3
|
||||
therm = therm_db;
|
||||
elseif nargin == 3
|
||||
therm = ' ';
|
||||
elseif nargin < 3
|
||||
error('syntax error: not enough arguments');
|
||||
end
|
||||
|
||||
lasterr('');
|
||||
|
||||
if isa(th,'Thermo') & isa(k,'Kinetics') & isa(infile,'char') & isa(therm,'char')
|
||||
ok = import_from_file(hndl(th), hndl(k), infile, therm, ' ', 1);
|
||||
if ok == -1
|
||||
error(geterr);
|
||||
elseif ok == -999
|
||||
disp('exception');
|
||||
error(lasterr);
|
||||
elseif ok < 0
|
||||
error('Error importing file');
|
||||
end
|
||||
|
||||
else
|
||||
error('syntax error');
|
||||
end
|
||||
b = {th, k};
|
||||
|
|
@ -6,9 +6,9 @@
|
|||
*/
|
||||
|
||||
#include "mex.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include "../../../clib/src/ctonedim.h"
|
||||
#include "../../../clib/src/ctxml.h"
|
||||
#include <cantera/clib/ct.h>
|
||||
#include <cantera/clib/ctonedim.h>
|
||||
#include <cantera/clib/ctxml.h>
|
||||
#include "ctmatutils.h"
|
||||
#include <string.h>
|
||||
#include <iostream>
|
||||
|
|
@ -9,11 +9,8 @@
|
|||
* class is indicated by the first parameter in the call from MATLAB.
|
||||
*/
|
||||
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ct.h>
|
||||
#include <string>
|
||||
//#include "../../../src/base/ct_defs.h"
|
||||
//#include "../../../src/base/global.h"
|
||||
//#include "../../../src/base/logger.h"
|
||||
#include "mex.h"
|
||||
#include "ctmatutils.h"
|
||||
#include "mllogger.h"
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
#include "mex.h"
|
||||
#include "ctmatutils.h"
|
||||
#include "../../../clib/src/ctreactor.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ctreactor.h>
|
||||
#include <cantera/clib/ct.h>
|
||||
|
||||
|
||||
//const double Undef = -999.123;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
#include "mex.h"
|
||||
#include "ctmatutils.h"
|
||||
#include "../../../clib/src/ctfunc.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ctfunc.h>
|
||||
#include <cantera/clib/ct.h>
|
||||
|
||||
void funcmethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "mex.h"
|
||||
#include "ctmatutils.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ct.h>
|
||||
|
||||
void checkNArgs(const int n, const int nrhs) {
|
||||
if (n != nrhs) {
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
* $Id: mixturemethods.cpp,v 1.3 2009/07/11 16:43:12 hkmoffa Exp $
|
||||
*/
|
||||
#include "mex.h"
|
||||
#include "../../../clib/src/ctmultiphase.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ctmultiphase.h>
|
||||
#include <cantera/clib/ct.h>
|
||||
#include "ctmatutils.h"
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
#include "mex.h"
|
||||
#include "ctmatutils.h"
|
||||
#include "../../../clib/src/ctonedim.h"
|
||||
#include <cantera/clib/ctonedim.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#include "mex.h"
|
||||
#include "ctmatutils.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ct.h>
|
||||
|
||||
void phasemethods( int nlhs, mxArray *plhs[],
|
||||
int nrhs, const mxArray *prhs[] )
|
||||
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
#include "mex.h"
|
||||
#include "../../../clib/src/ctreactor.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ctreactor.h>
|
||||
#include <cantera/clib/ct.h>
|
||||
#include "ctmatutils.h"
|
||||
|
||||
void reactormethods( int nlhs, mxArray *plhs[],
|
||||
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
#include "mex.h"
|
||||
#include "../../../clib/src/ctreactor.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ctreactor.h>
|
||||
#include <cantera/clib/ct.h>
|
||||
#include "ctmatutils.h"
|
||||
|
||||
//const double Undef = -999.123;
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
#include "mex.h"
|
||||
#include "ctmatutils.h"
|
||||
#include "../../../clib/src/ctsurf.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ctsurf.h>
|
||||
#include <cantera/clib/ct.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
* $Id: thermomethods.cpp,v 1.11 2009/07/11 16:43:13 hkmoffa Exp $
|
||||
*/
|
||||
#include "mex.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ct.h>
|
||||
#include "ctmatutils.h"
|
||||
|
||||
static void thermoset( int nlhs, mxArray *plhs[],
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
|
||||
#include "mex.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ct.h>
|
||||
#include "ctmatutils.h"
|
||||
#include <fstream>
|
||||
|
||||
|
|
@ -5,8 +5,8 @@
|
|||
* $Id: wallmethods.cpp,v 1.5 2009/07/11 16:43:13 hkmoffa Exp $
|
||||
*/
|
||||
#include "mex.h"
|
||||
#include "../../../clib/src/ctreactor.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ctreactor.h>
|
||||
#include <cantera/clib/ct.h>
|
||||
#include "ctmatutils.h"
|
||||
|
||||
//const double Undef = -999.123;
|
||||
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
#include "mex.h"
|
||||
#include "../../../clib/src/ctxml.h"
|
||||
#include "../../../clib/src/ct.h"
|
||||
#include <cantera/clib/ctxml.h>
|
||||
#include <cantera/clib/ct.h>
|
||||
#include "ctmatutils.h"
|
||||
|
||||
void reportError();
|
||||
|
|
@ -2,6 +2,7 @@ from buildutils import *
|
|||
import platform, sys, os
|
||||
|
||||
env = Environment()
|
||||
env.AddMethod(RecursiveInstall)
|
||||
|
||||
# ******************************************************
|
||||
# *** Set system-dependent defaults for some options ***
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ def mglob(env, subdir, *args):
|
|||
else:
|
||||
matches += env.Glob(pjoin(subdir, '*.%s' % ext))
|
||||
return matches
|
||||
# return sum((env.Glob('%s/*.%s' % (subdir, ext)) for ext in args), [])
|
||||
|
||||
|
||||
def psplit(s):
|
||||
|
|
@ -100,3 +99,59 @@ def psplit(s):
|
|||
|
||||
path.reverse()
|
||||
return path
|
||||
|
||||
|
||||
# This tool adds the builder:
|
||||
#
|
||||
# env.RecursiveInstall(target, path)
|
||||
#
|
||||
# This is useful for doing:
|
||||
#
|
||||
# k = env.RecursiveInstall(dir_target, dir_source)
|
||||
#
|
||||
# and if any thing in dir_source is updated the install is rerun
|
||||
#
|
||||
# It behaves similar to the env.Install builtin. However it expects
|
||||
# two directories and correctly sets up the dependencies between each
|
||||
# sub file instead of just between the two directories.
|
||||
#
|
||||
# Note in also traverses the in memory node tree for the source
|
||||
# directory and can detect things that are not built yet. Internally
|
||||
# we use the env.Glob function for this support.
|
||||
#
|
||||
# You can see the effect of this function by doing:
|
||||
#
|
||||
# scons --tree=all,prune
|
||||
#
|
||||
# and see the one to one correspondence between source and target
|
||||
# files within each directory.
|
||||
|
||||
def RecursiveInstall(env, target, dir):
|
||||
nodes = _recursive_install(env, dir)
|
||||
|
||||
dir = env.Dir(dir).abspath
|
||||
target = env.Dir(target).abspath
|
||||
|
||||
l = len(dir) + 1
|
||||
|
||||
relnodes = [n.abspath[l:] for n in nodes]
|
||||
|
||||
out = []
|
||||
for n in relnodes:
|
||||
t = os.path.join(target, n)
|
||||
s = os.path.join(dir, n)
|
||||
out.extend(env.InstallAs(env.File(t), env.File(s)))
|
||||
|
||||
return out
|
||||
|
||||
def _recursive_install(env, path):
|
||||
nodes = env.Glob(os.path.join(path, '*'), strings=False)
|
||||
nodes.extend(env.Glob(os.path.join(path, '*.*'), strings=False))
|
||||
out = []
|
||||
for n in nodes:
|
||||
if n.isdir():
|
||||
out.extend(_recursive_install(env, n.abspath))
|
||||
else:
|
||||
out.append(n)
|
||||
|
||||
return out
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue