diff options
author | Greg Noel <GregNoel@tigris.org> | 2009-01-04 08:24:11 (GMT) |
---|---|---|
committer | Greg Noel <GregNoel@tigris.org> | 2009-01-04 08:24:11 (GMT) |
commit | c72683e53169e438837955dfcfcc3a21cf988d64 (patch) | |
tree | 66ae1607da773bf1241535070543cf2b61b90553 /src/engine/SCons/Tool/swig.py | |
parent | a46317bc7a48afe35b6d591146d231871837a5ae (diff) | |
download | SCons-c72683e53169e438837955dfcfcc3a21cf988d64.zip SCons-c72683e53169e438837955dfcfcc3a21cf988d64.tar.gz SCons-c72683e53169e438837955dfcfcc3a21cf988d64.tar.bz2 |
First part of issue 2278: handle quoted module names in SWIG source
Diffstat (limited to 'src/engine/SCons/Tool/swig.py')
-rw-r--r-- | src/engine/SCons/Tool/swig.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py index 16f938e..eb4ca79 100644 --- a/src/engine/SCons/Tool/swig.py +++ b/src/engine/SCons/Tool/swig.py @@ -51,7 +51,17 @@ def swigSuffixEmitter(env, source): return '$SWIGCFILESUFFIX' # Match '%module test', as well as '%module(directors="1") test' -_reModule = re.compile(r'%module(?:\s*\(.*\))?\s+(.+)') +# Also allow for test to be quoted (SWIG permits double quotes, but not single) +_reModule = re.compile(r'%module(\s*\(.*\))?\s+("?)(.+)\2') + +def _find_modules(src): + """Find all modules referenced by %module lines in `src`, a SWIG .i file. + Returns a list of all modules.""" + mnames = [] + matches = _reModule.findall(open(src).read()) + for m in matches: + mnames.append(m[2]) + return mnames def _swigEmitter(target, source, env): swigflags = env.subst("$SWIGFLAGS", target=target, source=source) @@ -61,12 +71,12 @@ def _swigEmitter(target, source, env): mnames = None if "-python" in flags and "-noproxy" not in flags: if mnames is None: - mnames = _reModule.findall(open(src).read()) + mnames = _find_modules(src) target.extend(map(lambda m, d=target[0].dir: d.File(m + ".py"), mnames)) if "-java" in flags: if mnames is None: - mnames = _reModule.findall(open(src).read()) + mnames = _find_modules(src) java_files = map(lambda m: [m + ".java", m + "JNI.java"], mnames) java_files = SCons.Util.flatten(java_files) outdir = env.subst('$SWIGOUTDIR', target=target, source=source) |