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

Annotation of /trunk/pygtk/SConscript

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2068 - (hide annotations) (download)
Fri Aug 21 02:48:14 2009 UTC (10 years, 11 months ago) by jpye
File size: 5285 byte(s)
Fix build of Python bindings for Mac OS X (Darwin).
1 jpye 2007 #!/usr/bin/env python
2 johnpye 387 Import('env')
3    
4 johnpye 908 import platform
5    
6 johnpye 387 srcs = Split("""
7 johnpye 770 library.cpp compiler.cpp type.cpp module.cpp symchar.cpp
8 johnpye 387 instance.cpp instanceinterfacedata.cpp
9 johnpye 1126 matrix.cpp method.cpp name.cpp
10 johnpye 387 reporter.cpp simulation.cpp set.cpp units.cpp dimensions.cpp extmethod.cpp
11 johnpye 869 variable.cpp registry.cpp relation.cpp
12 johnpye 387 solver.cpp curve.cpp plot.cpp
13     solverparameters.cpp solverparameter.cpp solverparameteriterator.cpp
14     solverstatus.cpp solverreporter.cpp
15     incidencematrix.cpp
16 johnpye 669 integrator.cpp
17     integratorreporter.cpp
18 johnpye 897 annotation.cpp
19 johnpye 387 """)
20    
21 johnpye 395 # Build a static library with all the sources
22    
23 jpye 1786 python_env = env.Clone()
24 johnpye 502
25 johnpye 552 if platform.system()=='Windows' and env.get('MSVS'):
26 johnpye 508 python_env.Append(CCFLAGS=['/EHsc']) # for exceptions (as suggested by a MSVC error msg, dunno if it's right or not -- JP)
27 johnpye 502
28 johnpye 509 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 johnpye 552 if env.get('HAVE_GCC'):
34 johnpye 979 #python_env.Append(CPPFLAGS=['-O3'])
35 johnpye 509 if swig_has_gccvisibility and env.has_key('HAVE_GCCVISIBILITY'):
36 johnpye 508 python_env.Append(CCFLAGS=['-fvisibility=hidden']);
37 johnpye 502
38 johnpye 463 objs = []
39 johnpye 508
40 jpye 2018 python_env.AppendUnique(
41     CPPPATH=env['PYTHON_CPPPATH']
42     )
43 johnpye 508
44 jpye 2018 print "PYTHON_CPPPATH = %s" % env['PYTHON_CPPPATH']
45    
46 johnpye 463 for s in srcs:
47 jpye 2018 objs += python_env.SharedObject(s)
48 johnpye 500
49 johnpye 398 #----------------------------------------------
50 johnpye 529 # SWIG wrapper
51 johnpye 398
52 johnpye 478 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 johnpye 482 flags += ['-O']
57 johnpye 1112 sep = ":"
58     if platform.system=="Windows": sep=";"
59    
60 jpye 2016 #print "FLAGS=%s" % env.get('GRAPHVIZ_CPPPATH')
61 jpye 1678 if env.get('WITH_GRAPHVIZ') and env.get('GRAPHVIZ_CPPPATH'):
62 jpye 1853 flags += ['-I%s' % i for i in env.get('GRAPHVIZ_CPPPATH')]
63 jpye 1720
64     if 'msvcr71' in env['LIBS']:
65     flags += ['-DHAVE_MSVCR71']
66    
67 johnpye 478 return flags
68 johnpye 395
69 jpye 1786 swig_env = python_env.Clone()
70 johnpye 929 if '-Wall' in swig_env.get('CCFLAGS'):
71     swig_env['CCFLAGS'] = swig_env['CCFLAGS'].remove('-Wall')
72 johnpye 925
73 jpye 1467 if platform.system()=="Windows":
74     swig_env['SHLIBSUFFIX']='.pyd'
75 jpye 2068 if 'msvcr71' in env.get('LIBS'):
76 jpye 1720 swig_env.Append(CPPDEFINES=['HAVE_MSVCR71'])
77 jpye 2068 elif platform.system()=="Darwin":
78     swig_env['SHLIBSUFFIX']='.so'
79 jpye 1467
80 johnpye 932 swigobjs = []
81 johnpye 519
82 johnpye 932 for swigf in Split("""
83     ascpy.i
84     """):
85     swigobj = swig_env.SharedObject(swigf
86     , SWIGFLAGS=['-python','-c++'] + get_new_swig_flags(env)
87     )
88 jpye 1786 #swig_env.SideEffect(['ascpy.py','ascpy_wrap.h'],'ascpy$SWIGCXXFILESUFFIX')
89 jpye 1440 swig_env.Depends('ascpy$SWIGCXXFILESUFFIX',['ascpy.i','solver.i','plot.i'])
90 johnpye 932 swig_env.Clean('ascpy_wrap$SWIGCXXFILESUFFIX',swigobj)
91     swig_env.Clean('ascpy.py','ascpy$SWIGCXXFILESUFFIX')
92     swig_env.Clean('ascpy_wrap.h','ascpy$SWIGCXXFILESUFFIX')
93    
94     swigobjs.append(swigobj)
95    
96 jpye 1720 swig_env.Append(LIBS = ['ascend']+env['PYTHON_LIB'])
97     swig_env.Append(LIBPATH = ['#'] + env['PYTHON_LIBPATH'])
98 johnpye 960 swig_env.Append(LINKFLAGS=env['PYTHON_LINKFLAGS'])
99 johnpye 938
100 johnpye 742 if not env.get('MSVS'):
101 johnpye 938 swig_env.Append(LIBS = ['stdc++'])
102 johnpye 742
103 johnpye 938 if env.get('WITH_DMALLOC'):
104     swig_env.Append(LIBS = ['dmalloc'])
105 johnpye 1111 swig_env.AppendUnique(LIBPATH = [env.get('DMALLOC_LIBPATH')])
106 johnpye 938
107 jpye 1678 if env.get('WITH_GRAPHVIZ'):
108     swig_env.Append(LIBS = env['GRAPHVIZ_LIBS'])
109     swig_env.AppendUnique(LIBPATH = [env.get('GRAPHVIZ_LIBPATH')])
110 johnpye 1111
111 johnpye 932 swiglib = swig_env.SharedLibrary("ascpy",objs + swigobjs
112 johnpye 392 , SHLIBPREFIX = '_'
113 johnpye 387 )
114 johnpye 529
115     #---------------------------------------------
116     # CONFIG & runtime shell script for posix
117    
118 johnpye 505 configpy = env.SubstInFile(source='config.py.in')
119     configh = env.SubstInFile(source='config.h.in')
120 johnpye 393
121 jpye 2027 ascendcmd = env.SubstInFile(source='ascend.in')
122     env.AddPostAction(ascendcmd, 'chmod 755 $TARGET')
123    
124 johnpye 529 if platform.system() != "Windows" or env.has_key('IS_MINGW'):
125 jpye 1786 envdev = env.Clone()
126 jpye 1747 # add 'WITH_SOLVERS' to the SUBST_DICT used by ascdev...
127     envdev['SUBST_DICT']['@WITH_SOLVERS@'] = ",".join(env.get('WITH_SOLVERS'))
128     ascdevcmd = envdev.SubstInFile(source='ascdev.in')
129 johnpye 858 env.AddPostAction(ascdevcmd, 'chmod 755 $TARGET')
130 johnpye 436
131 johnpye 435 #---------------------------------------------
132 johnpye 529 # LITTLE WEE TEST PROGRAM for debuggin the c++ wrapper
133 johnpye 961 # currently out of order because of need for a separate builddir due to ASCXX_WITH_PYTHON flag taking different value
134 johnpye 542 #
135     #libascxx = env.SharedLibrary('ascxx',objs
136     # , LIBS = ['ascend'] + env['PYTHON_LIB']
137     # , LIBPATH = ['.'] + ['#'] + env['PYTHON_LIBPATH']
138     #)
139 jpye 1803
140     ipopttest = swig_env.Program('testipopt',['testipopt.cpp'] + objs)
141 jpye 2039 conopttest = swig_env.Program('testconopt',['testconopt.cpp'] + objs)
142 jpye 1803
143 johnpye 542 #env.Alias('ascxx',ascxxtest)
144 johnpye 529
145     #---------------------------------------------
146 johnpye 435 # INSTALLATION
147    
148 jpye 1408 # python compile bytecode
149    
150     import py_compile
151     def pyc_build(target, source, env):
152     py_compile.compile(str(source[0]),str(target[0]),"",True)
153     return None
154     env.Append(BUILDERS = {'PYC' : Builder(action = pyc_build,suffix='.pyc',src_suffix='.py')})
155    
156 johnpye 552 if env.get('CAN_INSTALL'):
157 jpye 1436 env.InstallProgram(Dir(env.subst("$INSTALL_ROOT$INSTALL_BIN")),ascendcmd)
158 johnpye 435
159 johnpye 463 import glob
160     pythonfiles = glob.glob("*.py")
161 johnpye 435
162 jpye 1408 pythonpycs = []
163     for f in pythonfiles:
164     pythonpycs.append( env.PYC(f) )
165    
166     for f in pythonfiles + pythonpycs:
167 jpye 2016 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PYTHON")),f)
168 jpye 1408
169 jpye 2016 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PYTHON")),"config.py")
170 johnpye 435
171 johnpye 463 gladefiles = glob.glob("glade/*")
172 jpye 1436 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_ASCDATA/glade")),gladefiles)
173 johnpye 435
174 jpye 2007 env.InstallShared(Dir(env.subst("$INSTALL_ROOT$INSTALL_PYTHON")),swiglib)
175 jpye 1465
176 johnpye 811 # vim: set syntax=python:
177    

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