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

Annotation of /trunk/ascxx/SConscript

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2419 - (hide annotations) (download)
Tue Mar 15 12:32:20 2011 UTC (11 years, 5 months ago) by jpye
File size: 4482 byte(s)
Fix accidental packaging of ascpy.py from old dir structure.
Fix default bintoken behaviour to NOT building bintokens.
Remove redundant -static-libstdc++ caluse in ascxx/SConscript.
1 jpye 2327 #!/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 '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 'msvcr71' in env.get('LIBS'):
78     swig_env.Append(CPPDEFINES=['HAVE_MSVCR71'])
79     elif platform.system()=="Darwin":
80     swig_env['SHLIBSUFFIX']='.so'
81    
82     swigobjs = []
83    
84     for swigf in Split("""
85     ascpy.i
86     """):
87     swigobj = swig_env.SharedObject(swigf
88     , SWIGFLAGS=['-python','-c++'] + get_new_swig_flags(env)
89     )
90     #swig_env.SideEffect(['ascpy.py','ascpy_wrap.h'],'ascpy$SWIGCXXFILESUFFIX')
91     swig_env.Depends('ascpy$SWIGCXXFILESUFFIX',['ascpy.i','solver.i','plot.i'])
92     swig_env.Clean('ascpy_wrap$SWIGCXXFILESUFFIX',swigobj)
93     swig_env.Clean('ascpy.py','ascpy$SWIGCXXFILESUFFIX')
94     swig_env.Clean('ascpy_wrap.h','ascpy$SWIGCXXFILESUFFIX')
95    
96     swigobjs.append(swigobj)
97    
98     swig_env.Append(LIBS = ['ascend']+env['PYTHON_LIB'])
99     swig_env.Append(LIBPATH = ['#'] + env['PYTHON_LIBPATH'])
100     swig_env.Append(LINKFLAGS=env['PYTHON_LINKFLAGS'])
101    
102 jpye 2416 libcxx = 'link'
103     if env.get('MSVS'):
104     libcxx = None
105     if platform.system()=="Windows" and env.get('HAVE_GCC'):
106     libcxx = 'static'
107    
108     if libcxx == 'link':
109 jpye 2327 swig_env.Append(LIBS = ['stdc++'])
110 jpye 2416 elif libcxx == 'static':
111     swig_env.Append(LINKFLAGS = ['-static-libstdc++'])
112    
113 jpye 2327 if env.get('WITH_DMALLOC'):
114     swig_env.Append(LIBS = ['dmalloc'])
115     swig_env.AppendUnique(LIBPATH = [env.get('DMALLOC_LIBPATH')])
116    
117     if env.get('WITH_GRAPHVIZ'):
118     swig_env.Append(LIBS = env['GRAPHVIZ_LIBS'])
119     swig_env.AppendUnique(LIBPATH = [env.get('GRAPHVIZ_LIBPATH')])
120    
121     swiglib = swig_env.SharedLibrary("ascpy",objs + swigobjs
122     , SHLIBPREFIX = '_'
123     )
124    
125     #---------------------------------------------
126     # CONFIG & runtime shell script for posix
127    
128     configh = env.SubstInFile(source='config.h.in')
129    
130     #---------------------------------------------
131     # LITTLE WEE TEST PROGRAM for debuggin the c++ wrapper
132     # currently out of order because of need for a separate builddir due to ASCXX_WITH_PYTHON flag taking different value
133     #
134     #libascxx = env.SharedLibrary('ascxx',objs
135     # , LIBS = ['ascend'] + env['PYTHON_LIB']
136     # , LIBPATH = ['.'] + ['#'] + env['PYTHON_LIBPATH']
137     #)
138    
139     ipopttest = swig_env.Program('testipopt',['testipopt.cpp'] + objs)
140     conopttest = swig_env.Program('testconopt',['testconopt.cpp'] + objs)
141     slvreqtest = swig_env.Program('testslvreq',['testslvreq.cpp'] + objs)
142    
143     #env.Alias('ascxx',ascxxtest)
144    
145     #---------------------------------------------
146     # INSTALLATION
147    
148     # python compile bytecode
149    
150     if env.get('CAN_INSTALL'):
151     env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PYTHON_ASCEND")),swiglib)
152 jpye 2391 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PYTHON_ASCEND")),'ascpy.py')
153 jpye 2327
154     # vim: set syntax=python:
155    

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