third_party/waf: upgrade to waf 2.0.8
[vlendec/samba-autobuild/.git] / third_party / waf / waflib / extras / protoc.py
index cb16e858182618f14b4c56d40fa248a9ffdec379..f3cb4d86ab84fcdcf87b5ebc672a472f5b65034c 100644 (file)
@@ -1,7 +1,3 @@
-#! /usr/bin/env python
-# encoding: utf-8
-# WARNING! Do not edit! https://waf.io/book/index.html#_obtaining_the_waf_file
-
 #!/usr/bin/env python
 # encoding: utf-8
 # Philipp Bender, 2012
@@ -128,6 +124,9 @@ class protoc(Task):
                                                        names.append(dep)
 
                parse_node(node)
+               # Add also dependencies path to INCPATHS so protoc will find the included file
+               for deppath in nodes:
+                       self.env.append_value('INCPATHS', deppath.parent.bldpath())
                return (nodes, names)
 
 @extension('.proto')
@@ -195,9 +194,9 @@ def process_protoc(self, node):
                        nodename += javacn + '.java'
                else:
                        if self.env.PROTOC_MAJOR > '2' and node.abspath()[node.abspath().rfind(os.sep)+1:node.abspath().rfind('.')].title() in messages:
-                               nodename += node.abspath()[node.abspath().rfind(os.sep)+1:node.abspath().rfind('.')].title() + 'OuterClass.java'
+                               nodename += node.abspath()[node.abspath().rfind(os.sep)+1:node.abspath().rfind('.')].title().replace('_','') + 'OuterClass.java'
                        else:
-                               nodename += node.abspath()[node.abspath().rfind(os.sep)+1:node.abspath().rfind('.')].title() + '.java'
+                               nodename += node.abspath()[node.abspath().rfind(os.sep)+1:node.abspath().rfind('.')].title().replace('_','') + '.java'
 
                java_node = node.parent.find_or_declare(nodename)
                out_nodes.append(java_node)
@@ -220,9 +219,14 @@ def process_protoc(self, node):
        # For C++ standard include files dirs are used,
        # but this doesn't apply to Python for example
        for incpath in getattr(self, 'protoc_includes', []):
-               incdirs.append(self.bld.path.find_node(incpath).bldpath())
+               incdirs.append(self.path.find_node(incpath).bldpath())
        tsk.env.PROTOC_INCPATHS = incdirs
 
+       # PR2115: protoc generates output of .proto files in nested
+       # directories  by canonicalizing paths. To avoid this we have to pass
+       # as first include the full directory file of the .proto file
+       tsk.env.prepend_value('INCPATHS', node.parent.bldpath())
+
        use = getattr(self, 'use', '')
        if not 'PROTOBUF' in use:
                self.use = self.to_list(use) + ['PROTOBUF']