All pastes #735168 Raw Edit

ph5

public text v1 · immutable
·published 2007-10-13 11:59 UTC
rendered paste body
Index: engine/swigwrappers/python/fife.i.templ===================================================================--- engine/swigwrappers/python/fife.i.templ	(revision 1714)+++ engine/swigwrappers/python/fife.i.templ	(working copy)@@ -9,4 +9,4 @@  $inclusions -%include swigwrappers/python/extensions.i.templ\ No newline at end of file+%include engine/swigwrappers/python/extensions.i.templIndex: engine/SConscript===================================================================--- engine/SConscript	(revision 1714)+++ engine/SConscript	(working copy)@@ -12,9 +12,9 @@ def is_headerfile(fname): 	return fname.endswith('.hpp') or fname.endswith('.h') -def generate_swig_wrappers(interfacefiles):+def generate_swig_wrappers(target, source, env): 	from string import Template-	swigoutdir = 'swigwrappers'+	swigoutdir = joinpath('engine', 'swigwrappers')  	def generate_language_specifics(lang): 		@@ -28,22 +28,39 @@ 		templatefile = joinpath(langoutdir,"fife.i.templ") 		 		template = Template(open(templatefile).read())-		inclusions = sorted(['%include ' + str(f) for f in interfacefiles])+		inclusions = sorted(['%include ' + str(f) for f in source]) 		inclusions = '\n'.join(inclusions)-		open('fife.i', 'w').write(template.substitute(inclusions=inclusions))-		-		pipe = os.popen(swigpath +'swig -c++ -%s -Icore fife.i' % (lang))+		interfacefile = joinpath(langoutdir, 'fife.i')+		open(interfacefile, 'w').write(template.substitute(inclusions=inclusions))++		includepath = joinpath('engine', 'core')+		pipe = os.popen(swigpath +'swig -c++ -%s -I%s -outdir %s %s' % (lang, includepath, langoutdir, interfacefile)) 		if pipe.close(): 			print "\nError while running swig, stopped" 			Exit(1)-		wrappers = enginepath.files('*fife*')-		for wrapper in wrappers:-			wrapper.move(langoutdir)  	print "Running swig..." 	generate_language_specifics(env['script']) 	print "Swig completed" +def swig_wrapper_emitter(target, source, env):+	target_append = []+	for t in target:+		t = str(t)+		if t.endswith('.py'):+			t = t[:-3]+		else:+			continue+		target_append.append(t + '.i')+		target_append.append(t + '_wrap.cxx')+		target_append.append(t + '_wrap.h')+	for t in target_append:+		target.append(t)+	return target, source++swig_wrapper_builder = Builder(action = generate_swig_wrappers, suffix = '.py', source_suffix = '.i', emitter = swig_wrapper_emitter)+env.Append(BUILDERS = {'SwigWrappers': swig_wrapper_builder})+ def remove_based_on_dir_filter(dirfilters, files): 	abspaths = [] 	for pathstr in dirfilters:@@ -76,22 +93,6 @@ 		for l in dupes: print l 		Exit(1) -def clean_generated_files():-	print "Cleaning generated files ..."-	for genfile in upath('swigwrappers').walkfiles():-		if str(genfile.abspath()).find('.svn') != -1:-			continue-		if genfile.endswith('.i.templ'):-			continue-		genfile.remove()--	EXPLICIT_REMOVES = ('fife.i', 'fife.py', 'fife_wrap.cxx', 'fife_wrap.h')-	for f in EXPLICIT_REMOVES:-		try:-			upath(f).remove()-		except:-			pass- def generate_msvc_project(projectfiles): 	def create_dict_tree(source_dict): 		for f in source_dict.keys():@@ -160,9 +161,10 @@ 	print "FIFE code::blocks project file succesfully created (%s)" % os.path.abspath(cbprojfilename)  -clean_generated_files() variated_dirs = eval(open(joinpath('config', 'variated_dirs'), 'r').read())-filteredpaths = []+# filter out swigwrappers. fife_wrap.cxx is appended manually+# as it might not exist yet during SConscript parsing+filteredpaths = ['swigwrappers'] for flag, paths in variated_dirs.items(): 	value = None 	if flag.find('-') != -1:@@ -178,8 +180,9 @@ 			interfacefiles.append(f[2:]) 		else: 			interfacefiles.append(f)-	generate_swig_wrappers(interfacefiles) +	env.SwigWrappers('swigwrappers/python/fife', interfacefiles)+ allfiles = list(enginepath.walkfiles()) headerfiles = [f for f in allfiles if is_headerfile(f)] implfiles = [f for f in allfiles if is_implfile(f)]@@ -197,6 +200,7 @@ 	print "Starting compilation" 	env.Append(CPPPATH = ['#/engine/core', '#/engine/swigwrappers']) 	compilefiles = [str(f) for f in remove_based_on_dir_filter(filteredpaths, implfiles)]+	compilefiles.append('./swigwrappers/%s/fife_wrap.cxx' % env['script']) 	flib = env.SharedLibrary('fife', compilefiles, LINKFLAGS=['-Wl,-rpath,../ext/install/lib,-rpath,ext/install/lib']) 	if sys.platform == 'linux2': 		env.Command('swigwrappers/%s/_fife.so' % env['script'], flib, [Copy('$TARGET', '$SOURCE')])