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

Contents of /trunk/pygtk/SConscript

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1786 - (show annotations) (download)
Sat Jun 7 06:17:35 2008 UTC (12 years ago) by jpye
File size: 5095 byte(s)
Fixed for missing libpython (DistutilsPlatformError).
Fixed several env.Copy() warnings.
Removed swig 'SideEffect' statement for current SCons swig tool.
1 Import('env')
2
3 import platform
4
5 srcs = Split("""
6 library.cpp compiler.cpp type.cpp module.cpp symchar.cpp
7 instance.cpp instanceinterfacedata.cpp
8 matrix.cpp method.cpp name.cpp
9 reporter.cpp simulation.cpp set.cpp units.cpp dimensions.cpp extmethod.cpp
10 variable.cpp registry.cpp relation.cpp
11 solver.cpp curve.cpp plot.cpp
12 solverparameters.cpp solverparameter.cpp solverparameteriterator.cpp
13 solverstatus.cpp solverreporter.cpp
14 incidencematrix.cpp
15 integrator.cpp
16 integratorreporter.cpp
17 annotation.cpp
18 """)
19
20 # Build a static library with all the sources
21
22 python_env = env.Clone()
23
24 if platform.system()=='Windows' and env.get('MSVS'):
25 python_env.Append(CCFLAGS=['/EHsc']) # for exceptions (as suggested by a MSVC error msg, dunno if it's right or not -- JP)
26
27 swig_has_gccvisibility = False
28 min,maj,pat = env['SWIGVERSION']
29 if min==1 and maj==3 and pat>=29:
30 swig_has_gccvisibility = True
31
32 if env.get('HAVE_GCC'):
33 #python_env.Append(CPPFLAGS=['-O3'])
34 if swig_has_gccvisibility and env.has_key('HAVE_GCCVISIBILITY'):
35 python_env.Append(CCFLAGS=['-fvisibility=hidden']);
36
37 objs = []
38
39 python_env.AppendUnique(CPPPATH=['#base/generic']+env['PYTHON_CPPPATH'])
40
41 for s in srcs:
42 objs += python_env.SharedObject(s)
43
44 #----------------------------------------------
45 # SWIG wrapper
46
47 def get_new_swig_flags(env):
48 min,maj,pat = env['SWIGVERSION']
49 flags = []
50 if min==1 and maj==3 and pat>=28:
51 flags += ['-O']
52 sep = ":"
53 if platform.system=="Windows": sep=";"
54
55 print "FLAGS=%s" % env.get('GRAPHVIZ_CPPPATH')
56 if env.get('WITH_GRAPHVIZ') and env.get('GRAPHVIZ_CPPPATH'):
57 flags += ['-I%s' % i for i in env.get('GRAPHVIZ_CPPPATH').split(sep)]
58
59 if 'msvcr71' in env['LIBS']:
60 flags += ['-DHAVE_MSVCR71']
61
62 return flags
63
64 swig_env = python_env.Clone()
65 if '-Wall' in swig_env.get('CCFLAGS'):
66 swig_env['CCFLAGS'] = swig_env['CCFLAGS'].remove('-Wall')
67
68 if platform.system()=="Windows":
69 swig_env['SHLIBSUFFIX']='.pyd'
70 if 'msvcr71' in env['LIBS']:
71 swig_env.Append(CPPDEFINES=['HAVE_MSVCR71'])
72
73 swigobjs = []
74
75 for swigf in Split("""
76 ascpy.i
77 """):
78 swigobj = swig_env.SharedObject(swigf
79 , SWIGFLAGS=['-python','-c++'] + get_new_swig_flags(env)
80 )
81 #swig_env.SideEffect(['ascpy.py','ascpy_wrap.h'],'ascpy$SWIGCXXFILESUFFIX')
82 swig_env.Depends('ascpy$SWIGCXXFILESUFFIX',['ascpy.i','solver.i','plot.i'])
83 swig_env.Clean('ascpy_wrap$SWIGCXXFILESUFFIX',swigobj)
84 swig_env.Clean('ascpy.py','ascpy$SWIGCXXFILESUFFIX')
85 swig_env.Clean('ascpy_wrap.h','ascpy$SWIGCXXFILESUFFIX')
86
87 swigobjs.append(swigobj)
88
89 swig_env.Append(LIBS = ['ascend']+env['PYTHON_LIB'])
90 swig_env.Append(LIBPATH = ['#'] + env['PYTHON_LIBPATH'])
91 swig_env.Append(LINKFLAGS=env['PYTHON_LINKFLAGS'])
92
93 if not env.get('MSVS'):
94 swig_env.Append(LIBS = ['stdc++'])
95
96 if env.get('WITH_DMALLOC'):
97 swig_env.Append(LIBS = ['dmalloc'])
98 swig_env.AppendUnique(LIBPATH = [env.get('DMALLOC_LIBPATH')])
99
100 if env.get('WITH_GRAPHVIZ'):
101 swig_env.Append(LIBS = env['GRAPHVIZ_LIBS'])
102 swig_env.AppendUnique(LIBPATH = [env.get('GRAPHVIZ_LIBPATH')])
103
104 swiglib = swig_env.SharedLibrary("ascpy",objs + swigobjs
105 , SHLIBPREFIX = '_'
106 )
107
108 #---------------------------------------------
109 # CONFIG & runtime shell script for posix
110
111 configpy = env.SubstInFile(source='config.py.in')
112 configh = env.SubstInFile(source='config.h.in')
113
114 if platform.system() != "Windows" or env.has_key('IS_MINGW'):
115 ascendcmd = env.SubstInFile(source='ascend.in')
116 env.AddPostAction(ascendcmd, 'chmod 755 $TARGET')
117
118 envdev = env.Clone()
119 # add 'WITH_SOLVERS' to the SUBST_DICT used by ascdev...
120 envdev['SUBST_DICT']['@WITH_SOLVERS@'] = ",".join(env.get('WITH_SOLVERS'))
121 ascdevcmd = envdev.SubstInFile(source='ascdev.in')
122 env.AddPostAction(ascdevcmd, 'chmod 755 $TARGET')
123
124 #---------------------------------------------
125 # LITTLE WEE TEST PROGRAM for debuggin the c++ wrapper
126 # currently out of order because of need for a separate builddir due to ASCXX_WITH_PYTHON flag taking different value
127 #
128 #libascxx = env.SharedLibrary('ascxx',objs
129 # , LIBS = ['ascend'] + env['PYTHON_LIB']
130 # , LIBPATH = ['.'] + ['#'] + env['PYTHON_LIBPATH']
131 #)
132 #
133 idatest = swig_env.Program('idatest',['idatest.cpp'] + objs)
134 #
135 #env.Alias('ascxx',ascxxtest)
136
137 #---------------------------------------------
138 # INSTALLATION
139
140 # python compile bytecode
141
142 import py_compile
143 def pyc_build(target, source, env):
144 py_compile.compile(str(source[0]),str(target[0]),"",True)
145 return None
146 env.Append(BUILDERS = {'PYC' : Builder(action = pyc_build,suffix='.pyc',src_suffix='.py')})
147
148 if env.get('CAN_INSTALL'):
149 env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendcmd)
150
151 import glob
152 pythonfiles = glob.glob("*.py")
153
154 pythonpycs = []
155 for f in pythonfiles:
156 pythonpycs.append( env.PYC(f) )
157
158 for f in pythonfiles + pythonpycs:
159 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_ASCDATA")),f)
160
161 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_ASCDATA")),"config.py")
162
163 gladefiles = glob.glob("glade/*")
164 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_ASCDATA/glade")),gladefiles)
165
166 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_ASCDATA")),swiglib)
167
168 # vim: set syntax=python:
169

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