Update SConstruct

This commit is contained in:
Sylvain Tricot 2020-03-22 00:06:43 +01:00
parent fbe1b6917b
commit 61202f7a1f
1 changed files with 48 additions and 12 deletions

View File

@ -1,8 +1,44 @@
from sysconfig import get_config_var
import os
SetOption('silent', True)
# Define the command line options
AddOption('--dbg',
dest='dbg',
action='store_true',
help='add debugging symbols')
AddOption('--verbose',
dest='verbose',
action='store_true',
help='add debugging symbols')
# define environments
COMP_OPTS = ['-O2', '-ffast-math', '-fno-automatic']
env = Environment(tools=['default', 'gfortran'], FORTRAN='gfortran', FORTRANFLAGS=" ".join(['-fPIC'] + COMP_OPTS))
#std = Environment(tools=['default', 'gfortran'], FORTRAN='gfortran',
std = Environment(FORTRAN='gfortran',
FORTRANFLAGS=['-fPIC', '-O2', '-ffast-math', '-fno-automatic'],
F2PY_OPTS=[],
FORTRANCOMSTR = "building $TARGET ...")
dbg = std.Clone()
dbg.Append(FORTRANFLAGS = ['-g', '-Wall', '-Wextra', '-Warray-temporaries', '-Wconversion', '-fbacktrace',
'-ffree-line-length-0', '-fcheck=all', '-ffpe-trap=zero,overflow,underflow',
'-finit-real=nan'])
dbg.Append(F2PY_OPTS = ['--debug-capi', '--debug'])
env = std
if GetOption('dbg'):
env = dbg
if GetOption('verbose'):
SetOption('silent', False)
#env.Replace(FORTRANCOMSTR = "")
suffix = get_config_var('EXT_SUFFIX')
sources = {
'dim_mod_src' : ['memalloc/dim_mod.f'],
@ -18,13 +54,11 @@ sources = {
objects = {}
for k, v in sources.items():
objects[k.replace('_src', '_obj')] = env.Object(sources[k])
objects[k.replace('_src', '_obj')] = env.Object(v)
Requires(objects['memalloc_obj'], objects['dim_mod_obj'])
suffix = get_config_var('EXT_SUFFIX')
cmd = "f2py3 -I. " + " ".join([str(_) for _ in objects if str(_).endswith('.o')]) + f" -c -m $MODULENAME $SOURCE"
shared_objects = {
'phd_se_noso_nosp_nosym': 'phd_se_noso_nosp_nosym/main.f',
@ -34,7 +68,9 @@ shared_objects = {
modules = {}
for k, v in shared_objects.items():
env['MODULENAME'] = k
modules[k] = env.Command(k + suffix, v, cmd)
Requires(modules[k], objects.values())
cmd = "f2py3 -I. " + " ".join([str(_) for _ in objects if str(_).endswith('.o')]) + f"$F2PY_OPTS -c -m {k} $SOURCE"
cmd += " 1>/dev/null"
modules[k + suffix] = env.Command(k + suffix, v, Action(cmd, 'Building Python module $TARGET'))
Requires(modules[k + suffix], objects.values())