Ensure link tasks are processed after swig tasks

This commit is contained in:
Thomas Nagy 2017-06-08 19:46:22 +02:00
parent 3e1e6586e5
commit ccf5961607
2 changed files with 15 additions and 2 deletions

View File

@ -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:

View File

@ -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):
"""