1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 06:23:53 +01:00

Merge pull request #13792 from benpicco/pkg/nanopb-fixes

pkg/nanopb: fix for proto files with includes
This commit is contained in:
Leandro Lanzieri 2020-04-08 10:37:20 +02:00 committed by GitHub
commit 1f24698a2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 2 deletions

View File

@ -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

View File

@ -5,4 +5,12 @@
* @brief Provides a protocol buffers library to RIOT
*
* @see https://github.com/nanopb/nanopb
*
* # Limitations
*
* The generated headers and includes from `.proto` files not accessible outside the
* module in which the `.proto` file is located.
*
* You can include `.proto` files that are not in the same directory by adding the
* directory of the `.proto` include to `PROTOBUF_PATH`.
*/

View File

@ -2,6 +2,7 @@
// one message.
syntax = "proto2";
import "nanopb.proto";
message SimpleMessage {
required int32 lucky_number = 1;