1 |
Import('env') |
2 |
|
3 |
import platform |
4 |
|
5 |
srcs = Split(""" |
6 |
library.cpp compiler.cpp type.cpp module.cpp symchar.cpp |
7 |
instance.cpp instanceinterfacedata.cpp |
8 |
matrix.cpp method.cpp name.cpp |
9 |
reporter.cpp simulation.cpp set.cpp units.cpp dimensions.cpp extmethod.cpp |
10 |
variable.cpp registry.cpp relation.cpp |
11 |
solver.cpp curve.cpp plot.cpp |
12 |
solverparameters.cpp solverparameter.cpp solverparameteriterator.cpp |
13 |
solverstatus.cpp solverreporter.cpp |
14 |
incidencematrix.cpp |
15 |
integrator.cpp |
16 |
integratorreporter.cpp |
17 |
annotation.cpp |
18 |
""") |
19 |
|
20 |
# Build a static library with all the sources |
21 |
|
22 |
python_env = env.Copy() |
23 |
|
24 |
if platform.system()=='Windows' and env.get('MSVS'): |
25 |
python_env.Append(CCFLAGS=['/EHsc']) # for exceptions (as suggested by a MSVC error msg, dunno if it's right or not -- JP) |
26 |
|
27 |
swig_has_gccvisibility = False |
28 |
min,maj,pat = env['SWIGVERSION'] |
29 |
if min==1 and maj==3 and pat>=29: |
30 |
swig_has_gccvisibility = True |
31 |
|
32 |
if env.get('HAVE_GCC'): |
33 |
#python_env.Append(CPPFLAGS=['-O3']) |
34 |
if swig_has_gccvisibility and env.has_key('HAVE_GCCVISIBILITY'): |
35 |
python_env.Append(CCFLAGS=['-fvisibility=hidden']); |
36 |
|
37 |
objs = [] |
38 |
|
39 |
python_env.AppendUnique(CPPPATH=['#base/generic']+env['PYTHON_CPPPATH']) |
40 |
|
41 |
for s in srcs: |
42 |
objs += python_env.SharedObject(s) |
43 |
|
44 |
#---------------------------------------------- |
45 |
# SWIG wrapper |
46 |
|
47 |
def get_new_swig_flags(env): |
48 |
min,maj,pat = env['SWIGVERSION'] |
49 |
flags = [] |
50 |
if min==1 and maj==3 and pat>=28: |
51 |
flags += ['-O'] |
52 |
sep = ":" |
53 |
if platform.system=="Windows": sep=";" |
54 |
|
55 |
print "FLAGS=%s" % env.get('MFGRAPH_CPPPATH') |
56 |
if env.get('WITH_MFGRAPH') and env.get('MFGRAPH_CPPPATH'): |
57 |
flags += ['-I%s' % i for i in env.get('MFGRAPH_CPPPATH').split(sep)] |
58 |
return flags |
59 |
|
60 |
swig_env = python_env.Copy() |
61 |
if '-Wall' in swig_env.get('CCFLAGS'): |
62 |
swig_env['CCFLAGS'] = swig_env['CCFLAGS'].remove('-Wall') |
63 |
|
64 |
swigobjs = [] |
65 |
|
66 |
for swigf in Split(""" |
67 |
ascpy.i |
68 |
"""): |
69 |
swigobj = swig_env.SharedObject(swigf |
70 |
, SWIGFLAGS=['-python','-c++'] + get_new_swig_flags(env) |
71 |
) |
72 |
swig_env.SideEffect(['ascpy.py','ascpy_wrap.h'],'ascpy$SWIGCXXFILESUFFIX') |
73 |
swig_env.Depends('ascpy_wrap.py',['ascpy.i','solver.i']) |
74 |
swig_env.Clean('ascpy_wrap$SWIGCXXFILESUFFIX',swigobj) |
75 |
swig_env.Clean('ascpy.py','ascpy$SWIGCXXFILESUFFIX') |
76 |
swig_env.Clean('ascpy_wrap.h','ascpy$SWIGCXXFILESUFFIX') |
77 |
|
78 |
swigobjs.append(swigobj) |
79 |
|
80 |
swig_env['LIBS'] = ['ascend']+env['PYTHON_LIB'] |
81 |
swig_env['LIBPATH'] = ['#'] + env['PYTHON_LIBPATH'] |
82 |
swig_env.Append(LINKFLAGS=env['PYTHON_LINKFLAGS']) |
83 |
|
84 |
if not env.get('MSVS'): |
85 |
swig_env.Append(LIBS = ['stdc++']) |
86 |
|
87 |
if env.get('WITH_DMALLOC'): |
88 |
swig_env.Append(LIBS = ['dmalloc']) |
89 |
swig_env.AppendUnique(LIBPATH = [env.get('DMALLOC_LIBPATH')]) |
90 |
|
91 |
if env.get('WITH_MFGRAPH'): |
92 |
swig_env.Append(LIBS = ['mfgraph']) |
93 |
swig_env.AppendUnique(LIBPATH = [env.get('MFGRAPH_LIBPATH')]) |
94 |
|
95 |
swiglib = swig_env.SharedLibrary("ascpy",objs + swigobjs |
96 |
, SHLIBPREFIX = '_' |
97 |
) |
98 |
|
99 |
#--------------------------------------------- |
100 |
# CONFIG & runtime shell script for posix |
101 |
|
102 |
configpy = env.SubstInFile(source='config.py.in') |
103 |
configh = env.SubstInFile(source='config.h.in') |
104 |
|
105 |
if platform.system() != "Windows" or env.has_key('IS_MINGW'): |
106 |
ascendcmd = env.SubstInFile(source='ascend.in') |
107 |
env.AddPostAction(ascendcmd, 'chmod 755 $TARGET') |
108 |
ascdevcmd = env.SubstInFile(source='ascdev.in') |
109 |
env.AddPostAction(ascdevcmd, 'chmod 755 $TARGET') |
110 |
|
111 |
#--------------------------------------------- |
112 |
# LITTLE WEE TEST PROGRAM for debuggin the c++ wrapper |
113 |
# currently out of order because of need for a separate builddir due to ASCXX_WITH_PYTHON flag taking different value |
114 |
# |
115 |
#libascxx = env.SharedLibrary('ascxx',objs |
116 |
# , LIBS = ['ascend'] + env['PYTHON_LIB'] |
117 |
# , LIBPATH = ['.'] + ['#'] + env['PYTHON_LIBPATH'] |
118 |
#) |
119 |
# |
120 |
#ascxxtest = env.Program('ascxxtest',['ascxxtest.cpp'] |
121 |
# , LIBS = ['ascxx','ascend'] |
122 |
# , LIBPATH = ['.','#'] |
123 |
#) |
124 |
# |
125 |
#env.Alias('ascxx',ascxxtest) |
126 |
|
127 |
#--------------------------------------------- |
128 |
# INSTALLATION |
129 |
|
130 |
if env.get('CAN_INSTALL'): |
131 |
env.InstallProgram(env['INSTALL_ROOT']+env['INSTALL_BIN'],ascendcmd) |
132 |
|
133 |
import glob |
134 |
pythonfiles = glob.glob("*.py") |
135 |
|
136 |
env.InstallShared(env['INSTALL_ROOT']+env['INSTALL_ASCDATA']+"/",pythonfiles) |
137 |
env.InstallShared(env['INSTALL_ROOT']+env['INSTALL_ASCDATA']+"/","config.py") |
138 |
|
139 |
gladefiles = glob.glob("glade/*") |
140 |
env.InstallShared(env['INSTALL_ROOT']+env['INSTALL_ASCDATA']+"/glade/",gladefiles) |
141 |
|
142 |
env.InstallShared(env['INSTALL_ROOT']+env['INSTALL_ASCDATA']+"/",swiglib) |
143 |
|
144 |
if platform.system()=="Windows": |
145 |
env.Append(NSISDEFINES={'OUTFILE':env['WIN_INSTALLER_NAME']}) |
146 |
installer = env.Installer('create.nsi') |
147 |
Depends(installer,[swiglib,configpy,configh,"../models","../ascend-config"]) |
148 |
env.Alias('installer',installer) |
149 |
|
150 |
# vim: set syntax=python: |
151 |
|