comparison engine/SConscript @ 175:ea04dfe54aae

* Buildscripts have been modified to work with different python versions. This applys only to linux/freebsd/darwin. For windows the only supported python version remains 2.5.x. On linux/freebsd/darwin 2.5 and 2.6 should work.
author nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
date Sun, 25 Jan 2009 19:07:57 +0000
parents ab8b11adfb70
children 1587ff8fa3a0
comparison
equal deleted inserted replaced
174:362fe23920b9 175:ea04dfe54aae
21 swigpath = '' 21 swigpath = ''
22 if sys.platform == 'win32': 22 if sys.platform == 'win32':
23 swigpath = '"' + os.environ['_SWIG'] + '"\\' 23 swigpath = '"' + os.environ['_SWIG'] + '"\\'
24 24
25 print " Generating language specific wrappers for " + lang 25 print " Generating language specific wrappers for " + lang
26 26
27 langoutdir = joinpath(swigoutdir, lang) 27 langoutdir = joinpath(swigoutdir, lang)
28 templatefile = joinpath(langoutdir,"fife.i.templ") 28 templatefile = joinpath(langoutdir,"fife.i.templ")
29 29
30 template = Template(open(templatefile).read()) 30 template = Template(open(templatefile).read())
31 inclusions = sorted(['%include ' + str(f) for f in source]) 31 inclusions = sorted(['%include ' + str(f) for f in source])
32 inclusions = '\n'.join(inclusions) 32 inclusions = '\n'.join(inclusions)
33 interfacefile = joinpath(langoutdir, 'fife.i') 33 interfacefile = joinpath(langoutdir, 'fife.i')
34 open(interfacefile, 'w').write(template.substitute(inclusions=inclusions)) 34 open(interfacefile, 'w').write(template.substitute(inclusions=inclusions))
109 source_dict[parts[0]][parts[1]] = {} 109 source_dict[parts[0]][parts[1]] = {}
110 del source_dict[f] 110 del source_dict[f]
111 for k, d in source_dict.items(): 111 for k, d in source_dict.items():
112 create_dict_tree(d) 112 create_dict_tree(d)
113 return source_dict 113 return source_dict
114 114
115 def get_msvc_repr(d, tabcount=2, curpath=''): 115 def get_msvc_repr(d, tabcount=2, curpath=''):
116 retstr = [] 116 retstr = []
117 for k in sorted(d.keys()): 117 for k in sorted(d.keys()):
118 newpath = os.path.join(curpath, k) 118 newpath = os.path.join(curpath, k)
119 if len(d[k].keys()): 119 if len(d[k].keys()):
122 retstr.append(tabcount * '\t' + '</Filter>') 122 retstr.append(tabcount * '\t' + '</Filter>')
123 else: 123 else:
124 newpath = os.path.join('..', '..', '..', '..', 'engine', newpath) 124 newpath = os.path.join('..', '..', '..', '..', 'engine', newpath)
125 retstr.append(tabcount * '\t' + '<File RelativePath="%s"></File>' % newpath.replace('/','\\')) 125 retstr.append(tabcount * '\t' + '<File RelativePath="%s"></File>' % newpath.replace('/','\\'))
126 return '\n'.join(retstr) 126 return '\n'.join(retstr)
127 127
128 vcpaths = [os.path.abspath(str(f)).split('%sengine%s' % (_sep, _sep))[-1] for f in source] 128 vcpaths = [os.path.abspath(str(f)).split('%sengine%s' % (_sep, _sep))[-1] for f in source]
129 xmlstr = get_msvc_repr(create_dict_tree(dict([[p, {}] for p in vcpaths]))) 129 xmlstr = get_msvc_repr(create_dict_tree(dict([[p, {}] for p in vcpaths])))
130 projtxt = open(joinpath(msvcbuildpath, 'engine_template.xml'), 'r').read() 130 projtxt = open(joinpath(msvcbuildpath, 'engine_template.xml'), 'r').read()
131 projtxt = projtxt.replace('__FILE_INSERTION_POINT__', xmlstr) 131 projtxt = projtxt.replace('__FILE_INSERTION_POINT__', xmlstr)
132 132
159 source_dict[parts[0]][parts[1]] = {} 159 source_dict[parts[0]][parts[1]] = {}
160 del source_dict[f] 160 del source_dict[f]
161 for k, d in source_dict.items(): 161 for k, d in source_dict.items():
162 create_dict_tree(d) 162 create_dict_tree(d)
163 return source_dict 163 return source_dict
164 164
165 def get_msvc_repr(d, tabcount=2, curpath=''): 165 def get_msvc_repr(d, tabcount=2, curpath=''):
166 retstr = [] 166 retstr = []
167 for k in sorted(d.keys()): 167 for k in sorted(d.keys()):
168 newpath = os.path.join(curpath, k) 168 newpath = os.path.join(curpath, k)
169 if len(d[k].keys()): 169 if len(d[k].keys()):
172 retstr.append(tabcount * '\t' + '</Filter>') 172 retstr.append(tabcount * '\t' + '</Filter>')
173 else: 173 else:
174 newpath = os.path.join('..', '..', '..', '..', 'engine', newpath) 174 newpath = os.path.join('..', '..', '..', '..', 'engine', newpath)
175 retstr.append(tabcount * '\t' + '<File RelativePath="%s"></File>' % newpath.replace('/','\\')) 175 retstr.append(tabcount * '\t' + '<File RelativePath="%s"></File>' % newpath.replace('/','\\'))
176 return '\n'.join(retstr) 176 return '\n'.join(retstr)
177 177
178 vcpaths = [os.path.abspath(str(f)).split('%sengine%s' % (_sep, _sep))[-1] for f in source] 178 vcpaths = [os.path.abspath(str(f)).split('%sengine%s' % (_sep, _sep))[-1] for f in source]
179 xmlstr = get_msvc_repr(create_dict_tree(dict([[p, {}] for p in vcpaths]))) 179 xmlstr = get_msvc_repr(create_dict_tree(dict([[p, {}] for p in vcpaths])))
180 projtxt = open(joinpath(msvcbuildpath9, 'engine_template.xml'), 'r').read() 180 projtxt = open(joinpath(msvcbuildpath9, 'engine_template.xml'), 'r').read()
181 projtxt = projtxt.replace('__FILE_INSERTION_POINT__', xmlstr) 181 projtxt = projtxt.replace('__FILE_INSERTION_POINT__', xmlstr)
182 182
203 <Option compilerVar=""/> 203 <Option compilerVar=""/>
204 <Option compile="0"/> 204 <Option compile="0"/>
205 <Option link="0"/> 205 <Option link="0"/>
206 <Option target="default"/> 206 <Option target="default"/>
207 </Unit>''' 207 </Unit>'''
208 208
209 codeblocksCppDef = \ 209 codeblocksCppDef = \
210 ''' <Unit filename="..\..\..\..\engine\%s"> 210 ''' <Unit filename="..\..\..\..\engine\%s">
211 <Option compilerVar="CPP"/> 211 <Option compilerVar="CPP"/>
212 <Option target="default"/> 212 <Option target="default"/>
213 </Unit>''' 213 </Unit>'''
236 <Option compilerVar=""/> 236 <Option compilerVar=""/>
237 <Option compile="0"/> 237 <Option compile="0"/>
238 <Option link="0"/> 238 <Option link="0"/>
239 <Option target="default"/> 239 <Option target="default"/>
240 </Unit>''' 240 </Unit>'''
241 241
242 codeblocksCppDef = \ 242 codeblocksCppDef = \
243 ''' <Unit filename="../../../engine/%s"> 243 ''' <Unit filename="../../../engine/%s">
244 <Option compilerVar="CPP"/> 244 <Option compilerVar="CPP"/>
245 <Option target="default"/> 245 <Option target="default"/>
246 </Unit>''' 246 </Unit>'''
279 interfacefiles.append(f[2:]) 279 interfacefiles.append(f[2:])
280 else: 280 else:
281 interfacefiles.append(f) 281 interfacefiles.append(f)
282 282
283 swig = env.SwigWrappers('swigwrappers/python/fife', interfacefiles) 283 swig = env.SwigWrappers('swigwrappers/python/fife', interfacefiles)
284 env.Install('$PREFIX/lib/python2.5/site-packages/fife', ['swigwrappers/python/fife.py']) 284 env.Install('$PREFIX/lib/python%s/site-packages/fife'%sys.version[:3], ['swigwrappers/python/fife.py'])
285 285
286 allfiles = list(enginepath.walkfiles()) 286 allfiles = list(enginepath.walkfiles())
287 headerfiles = [f for f in allfiles if is_headerfile(f)] 287 headerfiles = [f for f in allfiles if is_headerfile(f)]
288 implfiles = [f for f in allfiles if is_implfile(f)] 288 implfiles = [f for f in allfiles if is_implfile(f)]
289 extensionfiles = list(extensionpath.walkfiles('*.py')) 289 extensionfiles = list(extensionpath.walkfiles('*.py'))
308 else: 308 else:
309 flib = env.SharedLibrary('fife', compilefiles, LINKFLAGS=['-Wl,-rpath,../../ext/install/lib,-rpath,../ext/install/lib,-rpath,ext/install/lib']) 309 flib = env.SharedLibrary('fife', compilefiles, LINKFLAGS=['-Wl,-rpath,../../ext/install/lib,-rpath,../ext/install/lib,-rpath,ext/install/lib'])
310 if sys.platform != 'win32': 310 if sys.platform != 'win32':
311 env.Command('swigwrappers/%s/_fife.so' % env['script'], flib, [Copy('$TARGET', '$SOURCE')]) 311 env.Command('swigwrappers/%s/_fife.so' % env['script'], flib, [Copy('$TARGET', '$SOURCE')])
312 if sys.platform != 'darwin': 312 if sys.platform != 'darwin':
313 env.Install('$PREFIX/lib/python2.5/site-packages/fife', flib) 313 env.Install('$PREFIX/lib/python%s/site-packages/fife'%sys.version[:3], flib)
314 # env.Install('$PREFIX/lib/python2.5/site-packages/fife', [str(f) for f in extensionfiles]) 314 # env.Install('$PREFIX/lib/python%s/site-packages/fife'%sys.version[:3], [str(f) for f in extensionfiles])