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

Contents of /trunk/pygtk/SConscript

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2027 - (show annotations) (download)
Thu Apr 30 08:27:56 2009 UTC (13 years, 7 months ago) by jpye
File size: 5143 byte(s)
Bump version to 0.9.6.
Documented changes since last release in CHANGELOG.txt
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 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.Clone()
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(
41 CPPPATH=env['PYTHON_CPPPATH']
42 )
43
44 print "PYTHON_CPPPATH = %s" % env['PYTHON_CPPPATH']
45
46 for s in srcs:
47 objs += python_env.SharedObject(s)
48
49 #----------------------------------------------
50 # SWIG wrapper
51
52 def get_new_swig_flags(env):
53 min,maj,pat = env['SWIGVERSION']
54 flags = []
55 if min==1 and maj==3 and pat>=28:
56 flags += ['-O']
57 sep = ":"
58 if platform.system=="Windows": sep=";"
59
60 #print "FLAGS=%s" % env.get('GRAPHVIZ_CPPPATH')
61 if env.get('WITH_GRAPHVIZ') and env.get('GRAPHVIZ_CPPPATH'):
62 flags += ['-I%s' % i for i in env.get('GRAPHVIZ_CPPPATH')]
63
64 if 'msvcr71' in env['LIBS']:
65 flags += ['-DHAVE_MSVCR71']
66
67 return flags
68
69 swig_env = python_env.Clone()
70 if '-Wall' in swig_env.get('CCFLAGS'):
71 swig_env['CCFLAGS'] = swig_env['CCFLAGS'].remove('-Wall')
72
73 if platform.system()=="Windows":
74 swig_env['SHLIBSUFFIX']='.pyd'
75 if 'msvcr71' in env['LIBS']:
76 swig_env.Append(CPPDEFINES=['HAVE_MSVCR71'])
77
78 swigobjs = []
79
80 for swigf in Split("""
81 ascpy.i
82 """):
83 swigobj = swig_env.SharedObject(swigf
84 , SWIGFLAGS=['-python','-c++'] + get_new_swig_flags(env)
85 )
86 #swig_env.SideEffect(['ascpy.py','ascpy_wrap.h'],'ascpy$SWIGCXXFILESUFFIX')
87 swig_env.Depends('ascpy$SWIGCXXFILESUFFIX',['ascpy.i','solver.i','plot.i'])
88 swig_env.Clean('ascpy_wrap$SWIGCXXFILESUFFIX',swigobj)
89 swig_env.Clean('ascpy.py','ascpy$SWIGCXXFILESUFFIX')
90 swig_env.Clean('ascpy_wrap.h','ascpy$SWIGCXXFILESUFFIX')
91
92 swigobjs.append(swigobj)
93
94 swig_env.Append(LIBS = ['ascend']+env['PYTHON_LIB'])
95 swig_env.Append(LIBPATH = ['#'] + env['PYTHON_LIBPATH'])
96 swig_env.Append(LINKFLAGS=env['PYTHON_LINKFLAGS'])
97
98 if not env.get('MSVS'):
99 swig_env.Append(LIBS = ['stdc++'])
100
101 if env.get('WITH_DMALLOC'):
102 swig_env.Append(LIBS = ['dmalloc'])
103 swig_env.AppendUnique(LIBPATH = [env.get('DMALLOC_LIBPATH')])
104
105 if env.get('WITH_GRAPHVIZ'):
106 swig_env.Append(LIBS = env['GRAPHVIZ_LIBS'])
107 swig_env.AppendUnique(LIBPATH = [env.get('GRAPHVIZ_LIBPATH')])
108
109 swiglib = swig_env.SharedLibrary("ascpy",objs + swigobjs
110 , SHLIBPREFIX = '_'
111 )
112
113 #---------------------------------------------
114 # CONFIG & runtime shell script for posix
115
116 configpy = env.SubstInFile(source='config.py.in')
117 configh = env.SubstInFile(source='config.h.in')
118
119 ascendcmd = env.SubstInFile(source='ascend.in')
120 env.AddPostAction(ascendcmd, 'chmod 755 $TARGET')
121
122 if platform.system() != "Windows" or env.has_key('IS_MINGW'):
123 envdev = env.Clone()
124 # add 'WITH_SOLVERS' to the SUBST_DICT used by ascdev...
125 envdev['SUBST_DICT']['@WITH_SOLVERS@'] = ",".join(env.get('WITH_SOLVERS'))
126 ascdevcmd = envdev.SubstInFile(source='ascdev.in')
127 env.AddPostAction(ascdevcmd, 'chmod 755 $TARGET')
128
129 #---------------------------------------------
130 # LITTLE WEE TEST PROGRAM for debuggin the c++ wrapper
131 # currently out of order because of need for a separate builddir due to ASCXX_WITH_PYTHON flag taking different value
132 #
133 #libascxx = env.SharedLibrary('ascxx',objs
134 # , LIBS = ['ascend'] + env['PYTHON_LIB']
135 # , LIBPATH = ['.'] + ['#'] + env['PYTHON_LIBPATH']
136 #)
137
138 ipopttest = swig_env.Program('testipopt',['testipopt.cpp'] + objs)
139
140 #env.Alias('ascxx',ascxxtest)
141
142 #---------------------------------------------
143 # INSTALLATION
144
145 # python compile bytecode
146
147 import py_compile
148 def pyc_build(target, source, env):
149 py_compile.compile(str(source[0]),str(target[0]),"",True)
150 return None
151 env.Append(BUILDERS = {'PYC' : Builder(action = pyc_build,suffix='.pyc',src_suffix='.py')})
152
153 if env.get('CAN_INSTALL'):
154 env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendcmd)
155
156 import glob
157 pythonfiles = glob.glob("*.py")
158
159 pythonpycs = []
160 for f in pythonfiles:
161 pythonpycs.append( env.PYC(f) )
162
163 for f in pythonfiles + pythonpycs:
164 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PYTHON")),f)
165
166 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PYTHON")),"config.py")
167
168 gladefiles = glob.glob("glade/*")
169 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_ASCDATA/glade")),gladefiles)
170
171 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PYTHON")),swiglib)
172
173 # vim: set syntax=python:
174

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