From 4e3855f771430c57d8474280f5b39b3610a0d9d1 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Mon, 12 Sep 2011 18:54:57 +0100 Subject: [PATCH] waf 1.6: fix python bindings apiscan --- bindings/python/wscript | 32 ++++++++++++++++++-------------- src/wscript | 3 +++ 2 files changed, 21 insertions(+), 14 deletions(-) diff --git a/bindings/python/wscript b/bindings/python/wscript index 7d6563e5b..8c0c3d2bb 100644 --- a/bindings/python/wscript +++ b/bindings/python/wscript @@ -288,19 +288,18 @@ int main () def get_headers_map(bld): headers_map = {} # header => module for ns3headers in bld.all_task_gen: - if type(ns3headers).__name__ == 'ns3header_taskgen': # XXX: find less hackish way to compare + if 'ns3header' in getattr(ns3headers, "features", []): if ns3headers.module.endswith('-test'): continue - for h in ns3headers.to_list(ns3headers.source): + for h in ns3headers.to_list(ns3headers.headers): headers_map[os.path.basename(h)] = ns3headers.module return headers_map def get_module_path(bld, module): for ns3headers in bld.all_task_gen: - if type(ns3headers).__name__ == 'ns3header_taskgen': # XXX: find less hackish way to compare + if 'ns3header' in getattr(ns3headers, "features", []): if ns3headers.module == module: break - else: raise ValueError("Module %r not found" % module) return ns3headers.path.abspath() @@ -309,7 +308,7 @@ class apiscan_task(Task.TaskBase): """Uses gccxml to scan the file 'everything.h' and extract API definitions. """ after = 'gen_ns3_module_header ns3header' - before = 'cc cxx' + before = 'cc cxx command' color = "BLUE" def __init__(self, curdirnode, env, bld, target, cflags, module): self.bld = bld @@ -324,7 +323,7 @@ class apiscan_task(Task.TaskBase): return 'api-scan-%s\n' % (self.target,) def run(self): - top_builddir = self.curdirnode.find_dir('../..').abspath(self.env) + top_builddir = self.bld.bldnode.abspath() module_path = get_module_path(self.bld, self.module) headers_map = get_headers_map(self.bld) scan_header = os.path.join(top_builddir, "ns3", "%s-module.h" % self.module) @@ -334,7 +333,7 @@ class apiscan_task(Task.TaskBase): return 0 argv = [ - self.env['PYTHON'], + self.env['PYTHON'][0], os.path.join(self.curdirnode.abspath(), 'ns3modulescan-modular.py'), # scanning script top_builddir, self.module, @@ -364,11 +363,11 @@ def get_modules_and_headers(bld): ## find the headers object for this module headers = [] for ns3headers in bld.all_task_gen: - if type(ns3headers).__name__ != 'ns3header_taskgen': # XXX: find less hackish way to compare + if 'ns3header' not in getattr(ns3headers, "features", []): continue if ns3headers.module != module_name: continue - for source in ns3headers.to_list(ns3headers.source): + for source in ns3headers.to_list(ns3headers.headers): headers.append(os.path.basename(source)) retval[module_name] = (list(module.module_deps), headers) return retval @@ -395,7 +394,8 @@ class python_scan_task_collector(Task.TaskBase): # signal stop (we generated files into the source dir and WAF # can't cope with it, so we have to force the user to restart # WAF) - self.bld.generator.stop = 1 + self.bld.producer.stop = 1 + self.bld.producer.free_task_pool() return 0 @@ -407,7 +407,7 @@ class gen_ns3_compat_pymod_task(Task.Task): def run(self): assert len(self.outputs) == 1 - outfile = file(self.outputs[0].abspath(self.env), "w") + outfile = file(self.outputs[0].abspath(), "w") print >> outfile, "import warnings" print >> outfile, 'warnings.warn("the ns3 module is a compatibility layer '\ 'and should not be used in newly written code", DeprecationWarning, stacklevel=2)' @@ -466,16 +466,20 @@ def build(bld): scan_modules = Options.options.apiscan.split(',') print "Modules to scan: ", scan_modules for target, cflags in scan_targets: + group = bld.get_group(bld.current_group) for module in scan_modules: - apiscan_task(bld.path, env, bld, target, cflags, module) - python_scan_task_collector(bld.path, env, bld) + group.append(apiscan_task(bld.path, env, bld, target, cflags, module)) + group.append(python_scan_task_collector(bld.path, env, bld)) return if env['ENABLE_PYTHON_BINDINGS']: - task = gen_ns3_compat_pymod_task(env=env) + task = gen_ns3_compat_pymod_task(env=env.derive()) task.set_outputs(bld.path.find_or_declare("ns3.py")) task.dep_vars = ['PYTHON_MODULES_BUILT'] + task.bld = bld + grp = bld.get_group(bld.current_group) + grp.append(task) # note: the actual build commands for the python bindings are in # src/wscript, not here. diff --git a/src/wscript b/src/wscript index ba5d56e2c..011b24426 100644 --- a/src/wscript +++ b/src/wscript @@ -291,6 +291,9 @@ def create_obj(bld, *args): def ns3_python_bindings(bld): + if Options.options.apiscan: + return + # this method is called from a module wscript, so remember bld.path is not bindings/python! module_abs_src_path = bld.path.abspath() module = os.path.basename(module_abs_src_path)