diff --git a/playground/swig/wscript b/playground/swig/wscript index 2e720eee..096a5400 100644 --- a/playground/swig/wscript +++ b/playground/swig/wscript @@ -169,7 +169,7 @@ def exec_test_python(bld): proc = subprocess.Popen(''' PYTHONPATH=$PYTHONPATH:build/extend/python LD_LIBRARY_PATH=$LD_LIBRARY_PATH:build/extend/python:build/extend -python -c "import test_swig_waf; a=test_swig_waf.A(); print 'Testing: a.add(2, 3) ->', a.add(2, 3)" +python -c "import test_swig_waf; a=test_swig_waf.A(); print('Testing: a.add(2, 3) -> %r' % a.add(2, 3))" '''.replace('\n', ' '), shell=True) proc.wait() except: diff --git a/waflib/extras/swig.py b/waflib/extras/swig.py index 05e4cc1a..94629c78 100644 --- a/waflib/extras/swig.py +++ b/waflib/extras/swig.py @@ -5,7 +5,7 @@ import re from waflib import Task, Logs -from waflib.TaskGen import extension +from waflib.TaskGen import extension, feature, after_method from waflib.Configure import conf from waflib.Tools import c_preproc @@ -95,6 +95,7 @@ class swig(Task.Task): swig_langs = {} def swigf(fun): swig_langs[fun.__name__.replace('swig_', '')] = fun + return fun swig.swigf = swigf def swig_c(self): @@ -160,6 +161,18 @@ def i_file(self, node): outdir.mkdir() tsk.outdir = outdir +@feature('c', 'cxx', 'd', 'fc', 'asm') +@after_method('apply_link', 'process_source') +def enforce_swig_before_link(self): + try: + link_task = self.link_task + except AttributeError: + pass + else: + for x in self.tasks: + if x.__class__.__name__ == 'swig': + link_task.run_after.add(x) + @conf def check_swig_version(conf, minver=None): """