pw_protobuf_compiler: nanopb include path

This change correctly sets the include path when generating nanopb
protobufs so that nanopb.proto can be imported.

Change-Id: I8bae55012978d77b09da038bdf9568b6c02145b2
diff --git a/pw_protobuf_compiler/nanopb_test.cc b/pw_protobuf_compiler/nanopb_test.cc
index e12a38e..4df3520 100644
--- a/pw_protobuf_compiler/nanopb_test.cc
+++ b/pw_protobuf_compiler/nanopb_test.cc
@@ -16,7 +16,8 @@
 #include "pw_protobuf_compiler_protos/nanopb_test.pb.h"
 
 TEST(Nanopb, CompilesProtobufs) {
-  pw_protobuf_compiler_Point point = {4, 8};
+  pw_protobuf_compiler_Point point = {4, 8, "point"};
   EXPECT_EQ(point.x, 4u);
   EXPECT_EQ(point.y, 8u);
+  EXPECT_EQ(sizeof(point.name), 16u);
 }
diff --git a/pw_protobuf_compiler/proto.gni b/pw_protobuf_compiler/proto.gni
index c03f11a..2d1c1a5 100644
--- a/pw_protobuf_compiler/proto.gni
+++ b/pw_protobuf_compiler/proto.gni
@@ -102,6 +102,8 @@
              "nanopb",
              "--module-path",
              "//",
+             "--include-paths",
+             "$dir_third_party_nanopb/generator/proto",
              "--out-dir",
              _proto_gen_dir,
              "--custom-plugin",
diff --git a/pw_protobuf_compiler/pw_protobuf_compiler_protos/nanopb_test.proto b/pw_protobuf_compiler/pw_protobuf_compiler_protos/nanopb_test.proto
index ac8ce59..3a02c41 100644
--- a/pw_protobuf_compiler/pw_protobuf_compiler_protos/nanopb_test.proto
+++ b/pw_protobuf_compiler/pw_protobuf_compiler_protos/nanopb_test.proto
@@ -13,9 +13,12 @@
 // the License.
 syntax = "proto3";
 
+import "nanopb.proto";
+
 package pw.protobuf_compiler;
 
 message Point {
   uint32 x = 1;
   uint32 y = 2;
+  string name = 3 [(nanopb).max_size = 16];
 };
diff --git a/pw_protobuf_compiler/py/pw_protobuf_compiler/generate_protos.py b/pw_protobuf_compiler/py/pw_protobuf_compiler/generate_protos.py
index bf54342..f8f4f6e 100644
--- a/pw_protobuf_compiler/py/pw_protobuf_compiler/generate_protos.py
+++ b/pw_protobuf_compiler/py/pw_protobuf_compiler/generate_protos.py
@@ -40,6 +40,10 @@
     parser.add_argument('--module-path',
                         required=True,
                         help='Path to the module containing the .proto files')
+    parser.add_argument('--include-paths',
+                        default=[],
+                        type=lambda arg: arg.split(';'),
+                        help='protoc include paths')
     parser.add_argument('--out-dir',
                         required=True,
                         help='Output directory for generated code')
@@ -90,8 +94,11 @@
         _LOG.error('Unsupported language: %s', args.language)
         return 1
 
+    include_paths = [f'-I{path}' for path in args.include_paths]
+
     return pw_cli.process.run(
         'protoc',
+        *include_paths,
         '-I',
         args.module_path,
         *lang_args,