[Scons-users] SWIG emitter patch
E.Z. Evgenii
dreamlands at hotmail.com
Fri Jan 19 13:56:37 EST 2018
Hello.
I ended up monkey-patching SWIG emitter to work when module name is not inside .i file, but provided with -module option instead. The latter is preferred for us, because we often need to base some names off this module name, and we don't want to have it in two places.
The original code in SCons/Tool/swig.py completely ignores this option and results in not emitting anything.
Here's a chunk of code I patched:
def _swigEmitter(target, source, env):
swigflags = env.subst("$SWIGFLAGS", target=target, source=source)
flags = SCons.Util.CLVar(swigflags)
for src in source:
src = str(src.rfile())
##### Replace this line: mnames = None
##### Begin patch
try:
mod_index = flags.index('-module')
mod_name = flags[mod_index+1]
mnames = [mod_name] if mod_name else None
except ValueError, IndexError:
mnames = None
directors = 0
##### end patch
if "-python" in flags and "-noproxy" not in flags:
# etc. etc.
I now get the .py file emitted (should work for other languages, as this is a language-independent section)
It would be nice to have that inside SCons, by default.
I am using 2.5.0, by the way.
Evgenii
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20180119/4e4b776d/attachment-0001.html>
More information about the Scons-users
mailing list