From 7c7b4e12fb90301a2d81170abb5840233ef6f322 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Mon, 18 Aug 2008 23:04:49 +0100 Subject: [PATCH] Don't scan python bindings until the everything.h file to be scanned is generated. Closes #288. --- bindings/python/wscript | 45 ++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/bindings/python/wscript b/bindings/python/wscript index 37e2b52e0..480fb1a0d 100644 --- a/bindings/python/wscript +++ b/bindings/python/wscript @@ -223,6 +223,7 @@ __dummy_function_to_force_template_instantiation (Ptr obj, TypeId typeId return 0 + class all_ns3_headers_taskgen(Object.task_gen): """Generates a 'everything.h' header file that includes some/all public ns3 headers. This single header file is to be parsed only once by gccxml, for greater efficiency. @@ -293,6 +294,33 @@ def get_modules_and_headers(): return retval + +class PythonScanTask(Task.TaskBase): + """Uses gccxml to scan the file 'everything.h' and extract API definitions. + """ + def __init__(self, curdirnode, env): + self.m_display = 'python-scan' + self.prio = 5 # everything.h has prio 4 + super(PythonScanTask, self).__init__() + self.curdirnode = curdirnode + self.env = env + + def run(self): + #print "Rescanning the python bindings..." + argv = [ + self.env['PYTHON'], + os.path.join(self.curdirnode.abspath(), 'ns3modulescan.py'), # scanning script + self.curdirnode.find_dir('../..').abspath(self.env), # include path (where the ns3 include dir is) + self.curdirnode.find_build('everything.h').abspath(self.env), + os.path.join(self.curdirnode.abspath(), 'ns3modulegen_generated.py'), # output file + ] + scan = subprocess.Popen(argv, stdin=subprocess.PIPE) + scan.stdin.write(repr(get_modules_and_headers())) + scan.stdin.close() + if scan.wait(): + raise SystemExit(1) + + def build(bld): if Params.g_options.python_disable: return @@ -307,22 +335,7 @@ def build(bld): if Params.g_options.python_scan: if not env['ENABLE_PYTHON_SCANNING']: Params.fatal("Cannot re-scan python bindings: (py)gccxml not available") - print "Rescanning the python bindings..." - curdir = bld.m_curdirnode.abspath() - argv = [ - env['PYTHON'], - os.path.join(curdir, 'ns3modulescan.py'), # scanning script - bld.m_curdirnode.find_dir('../..').abspath(env), # include path (where the ns3 include dir is) - bld.m_curdirnode.find_build('everything.h').abspath(env), - os.path.join(curdir, 'ns3modulegen_generated.py'), # output file - ] - scan = subprocess.Popen(argv, stdin=subprocess.PIPE) - scan.stdin.write(repr(get_modules_and_headers())) - scan.stdin.close() - if scan.wait(): - raise SystemExit(1) - print "Rescanning the python bindings done." - raise SystemExit + PythonScanTask(bld.m_curdirnode, env) ## Get a list of scanned modules; the set of scanned modules ## may be smaller than the set of all modules, in case a new