From 7fd329b3a196f44e82daffa2117e5af88f2406d4 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 2 Apr 2020 12:34:04 +0200 Subject: [PATCH] pkg/nanopb: fix for proto files with includes Proto files can include other proto files. E.g. nanopb comes with a `nanopb.proto` include that contains some nanopb-specific extensions. This patch makes it possible to include this file as well as specifying additional proto include folders. I added the include to `simple.proto` so it gets exercised by the test. --- pkg/nanopb/Makefile.gensrc | 11 +++++++++-- tests/pkg_nanopb/simple.proto | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/nanopb/Makefile.gensrc b/pkg/nanopb/Makefile.gensrc index 3a7f1b761c..fc82bf9944 100644 --- a/pkg/nanopb/Makefile.gensrc +++ b/pkg/nanopb/Makefile.gensrc @@ -2,13 +2,20 @@ PROTOC ?= protoc PROTOC_GEN_NANOPB ?= $(PKGDIRBASE)/nanopb/generator/protoc-gen-nanopb PROTOBUF_FILES ?= $(wildcard *.proto) +PROTOBUF_PATH ?= $(CURDIR) GENSRC += $(PROTOBUF_FILES:%.proto=$(BINDIR)/$(MODULE)/%.pb.c) GENOBJC := $(GENSRC:%.c=%.o) -ifneq (, $(PROTOBUF_FILES)) +ifneq (,$(PROTOBUF_FILES)) INCLUDES += -I$(BINDIR)/$(MODULE) endif +# workaround for old protoc +PROTO_INCLUDES += -I. +# add nanopb specific includes +PROTO_INCLUDES += -I$(PKGDIRBASE)/nanopb/generator/proto +PROTO_INCLUDES += -I$(PROTOBUF_PATH) + $(SRC): $(GENSRC) $(GENSRC): $(PROTOBUF_FILES) @@ -18,6 +25,6 @@ $(GENSRC): $(PROTOBUF_FILES) make -C $(PKGDIRBASE)/nanopb/generator/proto && \ for protofile in $(PROTOBUF_FILES); do \ protoc --plugin=protoc-gen-nanopb=$(PROTOC_GEN_NANOPB) \ - --nanopb_out="$$D" \ + --nanopb_out="$$D" $(PROTO_INCLUDES) \ $^ \ ; done diff --git a/tests/pkg_nanopb/simple.proto b/tests/pkg_nanopb/simple.proto index f6bc03d976..119a5ec64a 100644 --- a/tests/pkg_nanopb/simple.proto +++ b/tests/pkg_nanopb/simple.proto @@ -2,6 +2,7 @@ // one message. syntax = "proto2"; +import "nanopb.proto"; message SimpleMessage { required int32 lucky_number = 1;