Add current directory to include path for protoc (#499)
It appears that new protoc versions no longer have a default include
path and have a mandatory -I option. I think that unnecessarily breaks
many build processes, so at least for now this change will restore the
old behavior when no include paths are specified.
Users can specify `-I` option to `nanopb_generator.py` also and then
the current directory default will not be added.
diff --git a/generator/proto/_utils.py b/generator/proto/_utils.py
index 3d174d5..8ca51f3 100644
--- a/generator/proto/_utils.py
+++ b/generator/proto/_utils.py
@@ -23,16 +23,20 @@
Args:
argv: protoc CLI invocation, first item must be 'protoc'
"""
+
+ # Add current directory to include path if nothing else is specified
+ if not [x for x in argv if x.startswith('-I')]:
+ argv.append("-I.")
+
+ # Add default protoc include paths
+ nanopb_include = os.path.dirname(os.path.abspath(__file__))
+ argv.append('-I' + nanopb_include)
+
if has_grpcio_protoc():
import grpc_tools.protoc as protoc
import pkg_resources
proto_include = pkg_resources.resource_filename('grpc_tools', '_proto')
- nanopb_include = os.path.dirname(os.path.abspath(__file__))
-
- if not [x for x in argv if x.startswith('-I')]:
- argv = argv + ["-I."]
-
- argv = argv + ['-I' + proto_include, '-I' + nanopb_include]
+ argv.append('-I' + proto_include)
return protoc.main(argv)
else: