2018-09-16 14:48:35 +02:00
|
|
|
PROTOC ?= protoc
|
|
|
|
PROTOC_GEN_NANOPB ?= $(PKGDIRBASE)/nanopb/generator/protoc-gen-nanopb
|
|
|
|
|
|
|
|
PROTOBUF_FILES ?= $(wildcard *.proto)
|
2020-04-02 12:34:04 +02:00
|
|
|
PROTOBUF_PATH ?= $(CURDIR)
|
2018-09-16 14:48:35 +02:00
|
|
|
GENSRC += $(PROTOBUF_FILES:%.proto=$(BINDIR)/$(MODULE)/%.pb.c)
|
|
|
|
GENOBJC := $(GENSRC:%.c=%.o)
|
|
|
|
|
2020-04-02 12:34:04 +02:00
|
|
|
ifneq (,$(PROTOBUF_FILES))
|
2018-09-16 14:48:35 +02:00
|
|
|
INCLUDES += -I$(BINDIR)/$(MODULE)
|
|
|
|
endif
|
|
|
|
|
2020-04-02 12:34:04 +02:00
|
|
|
# workaround for old protoc
|
|
|
|
PROTO_INCLUDES += -I.
|
|
|
|
# add nanopb specific includes
|
|
|
|
PROTO_INCLUDES += -I$(PKGDIRBASE)/nanopb/generator/proto
|
|
|
|
PROTO_INCLUDES += -I$(PROTOBUF_PATH)
|
|
|
|
|
2021-05-27 16:07:07 +02:00
|
|
|
$(SRC) $(SRCXX): $(GENSRC)
|
2018-09-16 14:48:35 +02:00
|
|
|
|
|
|
|
$(GENSRC): $(PROTOBUF_FILES)
|
|
|
|
$(Q)D=$(BINDIR)/$(MODULE) && \
|
|
|
|
mkdir -p "$$D" && \
|
|
|
|
cd $(CURDIR) && \
|
2020-07-03 11:17:57 +02:00
|
|
|
$(MAKE) -C $(PKGDIRBASE)/nanopb/generator/proto && \
|
2018-09-16 14:48:35 +02:00
|
|
|
for protofile in $(PROTOBUF_FILES); do \
|
|
|
|
protoc --plugin=protoc-gen-nanopb=$(PROTOC_GEN_NANOPB) \
|
2020-04-02 12:34:04 +02:00
|
|
|
--nanopb_out="$$D" $(PROTO_INCLUDES) \
|
2018-09-16 14:48:35 +02:00
|
|
|
$^ \
|
|
|
|
; done
|