diff options
author | Russel Winder <russel@winder.org.uk> | 2015-12-24 16:32:14 (GMT) |
---|---|---|
committer | Russel Winder <russel@winder.org.uk> | 2015-12-24 16:32:14 (GMT) |
commit | 2a270c8f314e959c78e9deda29c8f250bb934dd6 (patch) | |
tree | 7008e644357036404f0861c8ba1bbbf43b2b4123 /src/engine/SCons/Tool/swig.py | |
parent | a7d764ed831fa3243aa0bd3307f641e1e1f9f8a8 (diff) | |
parent | 9d558dd65deacc958edc1f0da2dab1ec56ff4e4e (diff) | |
download | SCons-2a270c8f314e959c78e9deda29c8f250bb934dd6.zip SCons-2a270c8f314e959c78e9deda29c8f250bb934dd6.tar.gz SCons-2a270c8f314e959c78e9deda29c8f250bb934dd6.tar.bz2 |
Post merge commit for safety. Building Fortran code works, but tests fail.
Diffstat (limited to 'src/engine/SCons/Tool/swig.py')
-rw-r--r-- | src/engine/SCons/Tool/swig.py | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/src/engine/SCons/Tool/swig.py b/src/engine/SCons/Tool/swig.py index f669f83..9d1965d 100644 --- a/src/engine/SCons/Tool/swig.py +++ b/src/engine/SCons/Tool/swig.py @@ -39,9 +39,13 @@ import subprocess import SCons.Action import SCons.Defaults -import SCons.Scanner import SCons.Tool import SCons.Util +import SCons.Node + +verbose = False + +swigs = [ 'swig', 'swig3.0', 'swig2.0' ] SwigAction = SCons.Action.Action('$SWIGCOM', '$SWIGCOMSTR') @@ -117,24 +121,33 @@ def _swigEmitter(target, source, env): if outdir: java_files = [os.path.join(outdir, j) for j in java_files] java_files = list(map(env.fs.File, java_files)) + def t_from_s(t, p, s, x): + return t.dir + tsm = SCons.Node._target_from_source_map + tkey = len(tsm) + tsm[tkey] = t_from_s for jf in java_files: - t_from_s = lambda t, p, s, x: t.dir - SCons.Util.AddMethod(jf, t_from_s, 'target_from_source') + jf._func_target_from_source = tkey target.extend(java_files) return (target, source) -def _get_swig_version(env): +def _get_swig_version(env, swig): """Run the SWIG command line tool to get and return the version number""" - pipe = SCons.Action._subproc(env, [env['SWIG'], '-version'], + swig = env.subst(swig) + pipe = SCons.Action._subproc(env, SCons.Util.CLVar(swig) + ['-version'], stdin = 'devnull', stderr = 'devnull', stdout = subprocess.PIPE) if pipe.wait() != 0: return - out = SCons.Util.to_str (pipe.stdout.read()) - match = re.search(r'SWIG Version\s+(\S+)$', out, re.MULTILINE) + # MAYBE: out = SCons.Util.to_str (pipe.stdout.read()) + out = pipe.stdout.read() + match = re.search(r'SWIG Version\s+(\S+).*', out, re.MULTILINE) if match: + if verbose: print "Version is:%s"%match.group(1) return match.group(1) + else: + if verbose: print "Unable to detect version: [%s]"%out def generate(env): """Add Builders and construction variables for swig to an Environment.""" @@ -155,8 +168,9 @@ def generate(env): java_file.add_action('.i', SwigAction) java_file.add_emitter('.i', _swigEmitter) - env['SWIG'] = 'swig' - env['SWIGVERSION'] = _get_swig_version(env) + if 'SWIG' not in env: + env['SWIG'] = env.Detect(swigs) or swigs[0] + env['SWIGVERSION'] = _get_swig_version(env, env['SWIG']) env['SWIGFLAGS'] = SCons.Util.CLVar('') env['SWIGDIRECTORSUFFIX'] = '_wrap.h' env['SWIGCFILESUFFIX'] = '_wrap$CFILESUFFIX' @@ -168,11 +182,6 @@ def generate(env): env['_SWIGINCFLAGS'] = '$( ${_concat(SWIGINCPREFIX, SWIGPATH, SWIGINCSUFFIX, __env__, RDirs, TARGET, SOURCE)} $)' env['SWIGCOM'] = '$SWIG -o $TARGET ${_SWIGOUTDIR} ${_SWIGINCFLAGS} $SWIGFLAGS $SOURCES' - expr = '^[ \t]*%[ \t]*(?:include|import|extern)[ \t]*(<|"?)([^>\s"]+)(?:>|"?)' - scanner = SCons.Scanner.ClassicCPP("SWIGScan", ".i", "SWIGPATH", expr) - - env.Append(SCANNERS = scanner) - def exists(env): swig = env.get('SWIG') or env.Detect(['swig']) return swig |