/[ascend]/trunk/ascxx/SConscript
ViewVC logotype

Contents of /trunk/ascxx/SConscript

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2416 - (show annotations) (download)
Tue Mar 15 06:39:55 2011 UTC (11 years, 4 months ago) by jpye
File size: 4580 byte(s)
Add flags for static libstdc++ with MinGW (needed for GCC 4.x).
Switch NSIS installer to depend on PyGTK All-in-one installer, instead of the
separate PyGTK, PyCairo, PyGObject and GTK+ packages.
1 #!/usr/bin/env python
2 Import('env')
3
4 import platform
5
6 srcs = Split("""
7 library.cpp compiler.cpp type.cpp module.cpp symchar.cpp
8 instance.cpp instanceinterfacedata.cpp
9 matrix.cpp 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 solverhooks.cpp
14 solverparameters.cpp solverparameter.cpp solverparameteriterator.cpp
15 solverstatus.cpp solverreporter.cpp
16 value.cpp
17 incidencematrix.cpp
18 integrator.cpp
19 integratorreporter.cpp
20 annotation.cpp
21 """)
22
23 # Build a static library with all the sources
24
25 python_env = env.Clone()
26
27 if platform.system()=='Windows' and env.get('MSVS'):
28 python_env.Append(CCFLAGS=['/EHsc']) # for exceptions (as suggested by a MSVC error msg, dunno if it's right or not -- JP)
29
30 swig_has_gccvisibility = False
31 min,maj,pat = env['SWIGVERSION']
32 if min==1 and maj==3 and pat>=29:
33 swig_has_gccvisibility = True
34
35 if env.get('HAVE_GCC'):
36 #python_env.Append(CPPFLAGS=['-O3'])
37 if swig_has_gccvisibility and env.has_key('HAVE_GCCVISIBILITY'):
38 python_env.Append(CCFLAGS=['-fvisibility=hidden']);
39 # use static linking to libstdc++ on Windows
40 python_env.Append(LINKFLAGS=['-static-libstdc++'])
41
42 objs = []
43
44 python_env.AppendUnique(
45 CPPPATH=env['PYTHON_CPPPATH']
46 )
47
48 print "PYTHON_CPPPATH = %s" % env['PYTHON_CPPPATH']
49
50 for s in srcs:
51 objs += python_env.SharedObject(s)
52
53 #----------------------------------------------
54 # SWIG wrapper
55
56 def get_new_swig_flags(env):
57 min,maj,pat = env['SWIGVERSION']
58 flags = []
59 if min==1 and maj==3 and pat>=28:
60 flags += ['-O']
61 sep = ":"
62 if platform.system=="Windows": sep=";"
63
64 #print "FLAGS=%s" % env.get('GRAPHVIZ_CPPPATH')
65 if env.get('WITH_GRAPHVIZ') and env.get('GRAPHVIZ_CPPPATH'):
66 flags += ['-I%s' % i for i in env.get('GRAPHVIZ_CPPPATH')]
67
68 if 'msvcr71' in env['LIBS']:
69 flags += ['-DHAVE_MSVCR71']
70
71 return flags
72
73 swig_env = python_env.Clone()
74 if '-Wall' in swig_env.get('CCFLAGS'):
75 swig_env['CCFLAGS'] = swig_env['CCFLAGS'].remove('-Wall')
76
77 if platform.system()=="Windows":
78 swig_env['SHLIBSUFFIX']='.pyd'
79 if 'msvcr71' in env.get('LIBS'):
80 swig_env.Append(CPPDEFINES=['HAVE_MSVCR71'])
81 elif platform.system()=="Darwin":
82 swig_env['SHLIBSUFFIX']='.so'
83
84 swigobjs = []
85
86 for swigf in Split("""
87 ascpy.i
88 """):
89 swigobj = swig_env.SharedObject(swigf
90 , SWIGFLAGS=['-python','-c++'] + get_new_swig_flags(env)
91 )
92 #swig_env.SideEffect(['ascpy.py','ascpy_wrap.h'],'ascpy$SWIGCXXFILESUFFIX')
93 swig_env.Depends('ascpy$SWIGCXXFILESUFFIX',['ascpy.i','solver.i','plot.i'])
94 swig_env.Clean('ascpy_wrap$SWIGCXXFILESUFFIX',swigobj)
95 swig_env.Clean('ascpy.py','ascpy$SWIGCXXFILESUFFIX')
96 swig_env.Clean('ascpy_wrap.h','ascpy$SWIGCXXFILESUFFIX')
97
98 swigobjs.append(swigobj)
99
100 swig_env.Append(LIBS = ['ascend']+env['PYTHON_LIB'])
101 swig_env.Append(LIBPATH = ['#'] + env['PYTHON_LIBPATH'])
102 swig_env.Append(LINKFLAGS=env['PYTHON_LINKFLAGS'])
103
104 libcxx = 'link'
105 if env.get('MSVS'):
106 libcxx = None
107 if platform.system()=="Windows" and env.get('HAVE_GCC'):
108 libcxx = 'static'
109
110 if libcxx == 'link':
111 swig_env.Append(LIBS = ['stdc++'])
112 elif libcxx == 'static':
113 swig_env.Append(LINKFLAGS = ['-static-libstdc++'])
114
115 if env.get('WITH_DMALLOC'):
116 swig_env.Append(LIBS = ['dmalloc'])
117 swig_env.AppendUnique(LIBPATH = [env.get('DMALLOC_LIBPATH')])
118
119 if env.get('WITH_GRAPHVIZ'):
120 swig_env.Append(LIBS = env['GRAPHVIZ_LIBS'])
121 swig_env.AppendUnique(LIBPATH = [env.get('GRAPHVIZ_LIBPATH')])
122
123 swiglib = swig_env.SharedLibrary("ascpy",objs + swigobjs
124 , SHLIBPREFIX = '_'
125 )
126
127 #---------------------------------------------
128 # CONFIG & runtime shell script for posix
129
130 configh = env.SubstInFile(source='config.h.in')
131
132 #---------------------------------------------
133 # LITTLE WEE TEST PROGRAM for debuggin the c++ wrapper
134 # currently out of order because of need for a separate builddir due to ASCXX_WITH_PYTHON flag taking different value
135 #
136 #libascxx = env.SharedLibrary('ascxx',objs
137 # , LIBS = ['ascend'] + env['PYTHON_LIB']
138 # , LIBPATH = ['.'] + ['#'] + env['PYTHON_LIBPATH']
139 #)
140
141 ipopttest = swig_env.Program('testipopt',['testipopt.cpp'] + objs)
142 conopttest = swig_env.Program('testconopt',['testconopt.cpp'] + objs)
143 slvreqtest = swig_env.Program('testslvreq',['testslvreq.cpp'] + objs)
144
145 #env.Alias('ascxx',ascxxtest)
146
147 #---------------------------------------------
148 # INSTALLATION
149
150 # python compile bytecode
151
152 if env.get('CAN_INSTALL'):
153 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PYTHON_ASCEND")),swiglib)
154 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PYTHON_ASCEND")),'ascpy.py')
155
156 # vim: set syntax=python:
157

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22