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