Better default behavior for building the Matlab toolbox with SCons
If Matlab is found on the path, build the toolbox by default, otherwise skip it. If the toolbox is required and Matlab can't be found, exit with an error.
This commit is contained in:
parent
79b7686e63
commit
0982600bcd
2 changed files with 43 additions and 3 deletions
27
SConstruct
27
SConstruct
|
|
@ -33,7 +33,7 @@ opts.AddVariables(
|
|||
'', PathVariable.PathAccept),
|
||||
PathVariable('cantera_python_home', 'where to install the python package',
|
||||
'', PathVariable.PathAccept),
|
||||
EnumVariable('matlab_toolbox', '', 'n', ('y', 'n', 'default')),
|
||||
EnumVariable('matlab_toolbox', '', 'default', ('y', 'n', 'default')),
|
||||
PathVariable('matlab_cmd', 'Path to the matlab executable',
|
||||
'matlab', PathVariable.PathAccept),
|
||||
BoolVariable('f90_interface', 'Build Fortran90 interface?', False),
|
||||
|
|
@ -154,6 +154,19 @@ if env['python_package'] in ('full','default'):
|
|||
warnNoPython = True
|
||||
env['python_package'] = 'minimal'
|
||||
|
||||
|
||||
if env['matlab_toolbox'] == 'y' and which(env['matlab_cmd']) is None:
|
||||
print """ERROR: Unable to find the Matlab executable '%s'""" % env['matlab_cmd']
|
||||
sys.exit(1)
|
||||
elif env['matlab_toolbox'] == 'default':
|
||||
cmd = which(env['matlab_cmd'])
|
||||
if cmd is not None:
|
||||
env['matlab_toolbox'] = 'y'
|
||||
print """INFO: Building the Matlab toolbox using '%s'""" % cmd
|
||||
else:
|
||||
print """INFO: Skipping compilation of the Matlab toolbox. """
|
||||
|
||||
|
||||
# **************************************
|
||||
# *** Set options needed in config.h ***
|
||||
# **************************************
|
||||
|
|
@ -337,10 +350,18 @@ inst = env.Install('$ct_bindir', pjoin('bin', 'exp3to2.sh'))
|
|||
installTargets.extend(inst)
|
||||
|
||||
### Meta-targets ###
|
||||
build_cantera = Alias('build', buildTargets)
|
||||
build_demos = Alias('demos', demoTargets)
|
||||
|
||||
Default(build_cantera)
|
||||
def postBuildMessage(target, source, env):
|
||||
print "**************************************************************"
|
||||
print "Compiliation complete. Type '[sudo] scons install' to install."
|
||||
print "**************************************************************"
|
||||
|
||||
finish_build = env.Command('finish_build', [], postBuildMessage)
|
||||
env.Depends(finish_build, buildTargets)
|
||||
build_cantera = Alias('build', finish_build)
|
||||
|
||||
Default('build')
|
||||
|
||||
def postInstallMessage(target, source, env):
|
||||
v = sys.version_info
|
||||
|
|
|
|||
|
|
@ -102,6 +102,25 @@ def psplit(s):
|
|||
return path
|
||||
|
||||
|
||||
def which(program):
|
||||
""" Replicates the functionality of the 'which' shell command """
|
||||
import os
|
||||
def is_exe(fpath):
|
||||
return os.path.exists(fpath) and os.access(fpath, os.X_OK)
|
||||
|
||||
fpath, fname = os.path.split(program)
|
||||
if fpath:
|
||||
if is_exe(program):
|
||||
return program
|
||||
else:
|
||||
for path in os.environ["PATH"].split(os.pathsep):
|
||||
exe_file = os.path.join(path, program)
|
||||
if is_exe(exe_file):
|
||||
return exe_file
|
||||
|
||||
return None
|
||||
|
||||
|
||||
# This tool adds the builder:
|
||||
#
|
||||
# env.RecursiveInstall(target, path)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue