Modular bindings: don't always generate compat ns3.py, only when needed
authorGustavo J. A. M. Carneiro <gjc@inescporto.pt>
Mon, 28 Mar 2011 15:31:13 +0100
changeset 6961 ca0f33d08fd0
parent 6960 2df22891346b
child 6962 7df7b903d035
Modular bindings: don't always generate compat ns3.py, only when needed
bindings/python/wscript
--- a/bindings/python/wscript	Mon Mar 28 14:56:08 2011 +0100
+++ b/bindings/python/wscript	Mon Mar 28 15:31:13 2011 +0100
@@ -571,18 +571,14 @@
 
 
 
-class gen_ns3_compat_pymod_task(Task.TaskBase):
+class gen_ns3_compat_pymod_task(Task.Task):
     """Generates a 'ns3.py' compatibility module."""
     before = 'cc cxx gchx'
     color = 'BLUE'
-
-    def __init__(self, bld, output_file):
-        self.bld = bld
-        self.output_file = output_file
-        super(gen_ns3_compat_pymod_task, self).__init__(generator=self)
     
     def run(self):
-        outfile = file(self.output_file, "w")
+        assert len(self.outputs) == 1
+        outfile = file(self.outputs[0].abspath(self.env), "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)'
@@ -766,4 +762,7 @@
                          target='ns3/__init__.py')
 
     if env['ENABLE_PYTHON_BINDINGS'] and env['BINDINGS_TYPE'] in ('modular',):
-        gen = gen_ns3_compat_pymod_task(bld, bld.path.find_or_declare("ns3.py").bldpath(bld.env))
+        task = gen_ns3_compat_pymod_task(env)
+        task.set_outputs(bld.path.find_or_declare("ns3.py"))
+        task.dep_vars = ['PYTHON_MODULES_BUILT']
+