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

Contents of /trunk/ascxx/SConscript

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2432 - (show annotations) (download)
Sun Mar 27 01:30:29 2011 UTC (13 years, 5 months ago) by jpye
File size: 4565 byte(s)
Fixing tests for case where var absent.
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
40 objs = []
41
42 python_env.AppendUnique(
43 CPPPATH=env['PYTHON_CPPPATH']
44 )
45
46 print "PYTHON_CPPPATH = %s" % env['PYTHON_CPPPATH']
47
48 for s in srcs:
49 objs += python_env.SharedObject(s)
50
51 #----------------------------------------------
52 # SWIG wrapper
53
54 def get_new_swig_flags(env):
55 min,maj,pat = env['SWIGVERSION']
56 flags = []
57 if min==1 and maj==3 and pat>=28:
58 flags += ['-O']
59 sep = ":"
60 if platform.system=="Windows": sep=";"
61
62 #print "FLAGS=%s" % env.get('GRAPHVIZ_CPPPATH')
63 if env.get('WITH_GRAPHVIZ') and env.get('GRAPHVIZ_CPPPATH'):
64 flags += ['-I%s' % i for i in env.get('GRAPHVIZ_CPPPATH')]
65
66 if env.get('LIBS') and 'msvcr71' in env['LIBS']:
67 flags += ['-DHAVE_MSVCR71']
68
69 return flags
70
71 swig_env = python_env.Clone()
72 if '-Wall' in swig_env.get('CCFLAGS'):
73 swig_env['CCFLAGS'] = swig_env['CCFLAGS'].remove('-Wall')
74
75 if platform.system()=="Windows":
76 swig_env['SHLIBSUFFIX']='.pyd'
77 if env.get('LIBS') and 'msvcr71' in env['LIBS']:
78 swig_env.Append(CPPDEFINES=['HAVE_MSVCR71'])
79 swig_env.Append(LINKFLAGS="-static-libgcc ")
80
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