/[ascend]/branches/georgy/ascxx/SConscript
ViewVC logotype

Contents of /branches/georgy/ascxx/SConscript

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3141 - (show annotations) (download)
Sun Jun 26 21:19:55 2016 UTC (4 years, 4 months ago) by georgy
File size: 4409 byte(s)
Fix SWIG compilation and Python lib paths.
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 #TDM-GCC not *not* require or support the following:
81 #swig_env.Append(LINKFLAGS="-static-libstdc++")
82
83 elif platform.system()=="Darwin":
84 swig_env['SHLIBSUFFIX']='.so'
85
86 swigobjs = []
87
88 for swigf in Split("""
89 ascpy.i
90 """):
91 swigobj = swig_env.SharedObject(swigf
92 , SWIGFLAGS=['-python','-c++'] + get_new_swig_flags(env)
93 )
94 #swig_env.SideEffect(['ascpy.py','ascpy_wrap.h'],'ascpy$SWIGCXXFILESUFFIX')
95 swig_env.Depends('ascpy$SWIGCXXFILESUFFIX',['ascpy.i','solver.i','plot.i'])
96 swig_env.Clean('ascpy_wrap$SWIGCXXFILESUFFIX',swigobj)
97 swig_env.Clean('ascpy.py','ascpy$SWIGCXXFILESUFFIX')
98 swig_env.Clean('ascpy_wrap.h','ascpy$SWIGCXXFILESUFFIX')
99
100 swigobjs.append(swigobj)
101
102 swig_env.Append(LIBS = ['ascend']+env['PYTHON_LIBS'])
103 swig_env.Append(LIBPATH = ['#'] + list(env['PYTHON_LIBPATH']))
104 swig_env.Append(LINKFLAGS=env['PYTHON_LINKFLAGS'])
105
106 if env.get('WITH_DMALLOC'):
107 swig_env.Append(LIBS = ['dmalloc'])
108 swig_env.AppendUnique(LIBPATH = [env.get('DMALLOC_LIBPATH')])
109
110 if env.get('WITH_GRAPHVIZ'):
111 swig_env.Append(LIBS = env['GRAPHVIZ_LIBS'])
112 swig_env.AppendUnique(LIBPATH = [env.get('GRAPHVIZ_LIBPATH')])
113
114 swiglib = swig_env.SharedLibrary("ascpy",objs + swigobjs
115 , SHLIBPREFIX = '_'
116 )
117
118 #---------------------------------------------
119 # CONFIG & runtime shell script for posix
120
121 configh = env.SubstInFile(source='config.h.in')
122
123 #---------------------------------------------
124 # LITTLE WEE TEST PROGRAM for debuggin the c++ wrapper
125 # currently out of order because of need for a separate builddir due to ASCXX_WITH_PYTHON flag taking different value
126 #
127 #libascxx = env.SharedLibrary('ascxx',objs
128 # , LIBS = ['ascend'] + env['PYTHON_LIB']
129 # , LIBPATH = ['.'] + ['#'] + env['PYTHON_LIBPATH']
130 #)
131
132 ipopttest = swig_env.Program('testipopt',['testipopt.cpp'] + objs)
133 conopttest = swig_env.Program('testconopt',['testconopt.cpp'] + objs)
134 slvreqtest = swig_env.Program('testslvreq',['testslvreq.cpp'] + objs)
135
136 #env.Alias('ascxx',ascxxtest)
137
138 #---------------------------------------------
139 # INSTALLATION
140
141 # python compile bytecode
142
143 if env.get('CAN_INSTALL'):
144 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PYTHON_ASCEND")),swiglib)
145 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PYTHON_ASCEND")),'ascpy.py')
146
147 # vim: set syntax=python:
148

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