mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
31 lines
849 B
Makefile
31 lines
849 B
Makefile
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))
|
|
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) $(SRCXX): $(GENSRC)
|
|
|
|
$(GENSRC): $(PROTOBUF_FILES)
|
|
$(Q)D=$(BINDIR)/$(MODULE) && \
|
|
mkdir -p "$$D" && \
|
|
cd $(CURDIR) && \
|
|
$(MAKE) -C $(PKGDIRBASE)/nanopb/generator/proto && \
|
|
for protofile in $(PROTOBUF_FILES); do \
|
|
protoc --plugin=protoc-gen-nanopb=$(PROTOC_GEN_NANOPB) \
|
|
--nanopb_out="$$D" $(PROTO_INCLUDES) \
|
|
$^ \
|
|
; done
|