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.
This commit is contained in:
parent
c74544c9ec
commit
7fd329b3a1
@ -2,13 +2,20 @@ PROTOC ?= protoc
|
|||||||
PROTOC_GEN_NANOPB ?= $(PKGDIRBASE)/nanopb/generator/protoc-gen-nanopb
|
PROTOC_GEN_NANOPB ?= $(PKGDIRBASE)/nanopb/generator/protoc-gen-nanopb
|
||||||
|
|
||||||
PROTOBUF_FILES ?= $(wildcard *.proto)
|
PROTOBUF_FILES ?= $(wildcard *.proto)
|
||||||
|
PROTOBUF_PATH ?= $(CURDIR)
|
||||||
GENSRC += $(PROTOBUF_FILES:%.proto=$(BINDIR)/$(MODULE)/%.pb.c)
|
GENSRC += $(PROTOBUF_FILES:%.proto=$(BINDIR)/$(MODULE)/%.pb.c)
|
||||||
GENOBJC := $(GENSRC:%.c=%.o)
|
GENOBJC := $(GENSRC:%.c=%.o)
|
||||||
|
|
||||||
ifneq (, $(PROTOBUF_FILES))
|
ifneq (,$(PROTOBUF_FILES))
|
||||||
INCLUDES += -I$(BINDIR)/$(MODULE)
|
INCLUDES += -I$(BINDIR)/$(MODULE)
|
||||||
endif
|
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)
|
$(SRC): $(GENSRC)
|
||||||
|
|
||||||
$(GENSRC): $(PROTOBUF_FILES)
|
$(GENSRC): $(PROTOBUF_FILES)
|
||||||
@ -18,6 +25,6 @@ $(GENSRC): $(PROTOBUF_FILES)
|
|||||||
make -C $(PKGDIRBASE)/nanopb/generator/proto && \
|
make -C $(PKGDIRBASE)/nanopb/generator/proto && \
|
||||||
for protofile in $(PROTOBUF_FILES); do \
|
for protofile in $(PROTOBUF_FILES); do \
|
||||||
protoc --plugin=protoc-gen-nanopb=$(PROTOC_GEN_NANOPB) \
|
protoc --plugin=protoc-gen-nanopb=$(PROTOC_GEN_NANOPB) \
|
||||||
--nanopb_out="$$D" \
|
--nanopb_out="$$D" $(PROTO_INCLUDES) \
|
||||||
$^ \
|
$^ \
|
||||||
; done
|
; done
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
// one message.
|
// one message.
|
||||||
|
|
||||||
syntax = "proto2";
|
syntax = "proto2";
|
||||||
|
import "nanopb.proto";
|
||||||
|
|
||||||
message SimpleMessage {
|
message SimpleMessage {
|
||||||
required int32 lucky_number = 1;
|
required int32 lucky_number = 1;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user