From cd18dad5ca1d031e124fa0df9381eb365e723288 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Sun, 16 Sep 2018 14:48:35 +0200 Subject: [PATCH] pkg: introduce nanoPb Protocol Buffers library --- Makefile.base | 4 +-- pkg/nanopb/Makefile | 11 +++++++++ pkg/nanopb/Makefile.gensrc | 23 ++++++++++++++++++ pkg/nanopb/Makefile.include | 1 + pkg/nanopb/Makefile.nanopb | 3 +++ pkg/nanopb/doc.txt | 8 ++++++ ...ator-nanopb_generator.py-use-python3.patch | Bin 0 -> 602 bytes 7 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 pkg/nanopb/Makefile create mode 100644 pkg/nanopb/Makefile.gensrc create mode 100644 pkg/nanopb/Makefile.include create mode 100644 pkg/nanopb/Makefile.nanopb create mode 100644 pkg/nanopb/doc.txt create mode 100644 pkg/nanopb/patches/0001-generator-nanopb_generator.py-use-python3.patch diff --git a/Makefile.base b/Makefile.base index 45548c6538..8f13e7d3b2 100644 --- a/Makefile.base +++ b/Makefile.base @@ -52,8 +52,8 @@ ifeq ($(strip $(ASSMSRC))$(NO_AUTO_SRC),) ASSMSRC := $(wildcard *.S) endif -# include makefile snippets that modify GENSRC here: -#include foo/bar.inc.mk +# include makefile snippets for packages in $(USEPKG) that modify GENSRC: +-include $(USEPKG:%=$(RIOTPKG)/%/Makefile.gensrc) GENOBJC := $(GENSRC:%.c=%.o) OBJC_LTO := $(SRC:%.c=$(BINDIR)/$(MODULE)/%.o) diff --git a/pkg/nanopb/Makefile b/pkg/nanopb/Makefile new file mode 100644 index 0000000000..1e43d8d56e --- /dev/null +++ b/pkg/nanopb/Makefile @@ -0,0 +1,11 @@ +PKG_NAME=nanopb +PKG_URL=https://github.com/nanopb/nanopb +PKG_VERSION=493adf3616bee052649c63c473f8355630c2797f # nanopb-0.3.9.4 +PKG_LICENSE=MIT + +.PHONY: all + +all: git-download + "$(MAKE)" -C $(PKG_BUILDDIR) -f $(CURDIR)/Makefile.nanopb + +include $(RIOTBASE)/pkg/pkg.mk diff --git a/pkg/nanopb/Makefile.gensrc b/pkg/nanopb/Makefile.gensrc new file mode 100644 index 0000000000..3a7f1b761c --- /dev/null +++ b/pkg/nanopb/Makefile.gensrc @@ -0,0 +1,23 @@ +PROTOC ?= protoc +PROTOC_GEN_NANOPB ?= $(PKGDIRBASE)/nanopb/generator/protoc-gen-nanopb + +PROTOBUF_FILES ?= $(wildcard *.proto) +GENSRC += $(PROTOBUF_FILES:%.proto=$(BINDIR)/$(MODULE)/%.pb.c) +GENOBJC := $(GENSRC:%.c=%.o) + +ifneq (, $(PROTOBUF_FILES)) + INCLUDES += -I$(BINDIR)/$(MODULE) +endif + +$(SRC): $(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" \ + $^ \ + ; done diff --git a/pkg/nanopb/Makefile.include b/pkg/nanopb/Makefile.include new file mode 100644 index 0000000000..f3a23fb596 --- /dev/null +++ b/pkg/nanopb/Makefile.include @@ -0,0 +1 @@ +INCLUDES += -I$(PKGDIRBASE)/nanopb diff --git a/pkg/nanopb/Makefile.nanopb b/pkg/nanopb/Makefile.nanopb new file mode 100644 index 0000000000..7c6055221b --- /dev/null +++ b/pkg/nanopb/Makefile.nanopb @@ -0,0 +1,3 @@ +SRCS := pb_encode.c pb_decode.c pb_common.c + +include $(RIOTBASE)/Makefile.base diff --git a/pkg/nanopb/doc.txt b/pkg/nanopb/doc.txt new file mode 100644 index 0000000000..def7d77601 --- /dev/null +++ b/pkg/nanopb/doc.txt @@ -0,0 +1,8 @@ +/** + * @defgroup pkg_nanopb small Protocol Buffers library + * @ingroup pkg + * @ingroup sys + * @brief Provides a protocol buffers library to RIOT + * + * @see https://github.com/nanopb/nanopb + */ diff --git a/pkg/nanopb/patches/0001-generator-nanopb_generator.py-use-python3.patch b/pkg/nanopb/patches/0001-generator-nanopb_generator.py-use-python3.patch new file mode 100644 index 0000000000000000000000000000000000000000..d8ed6a53438e0b7cc4b414fc1ecc938b08ea40a9 GIT binary patch literal 602 zcmaiy-AcqT5QXpODMq|;>9$SUZo?LliXwuD!g?oC(qy_D?WUzoMZt$RUDPX42qAMa zbLPv>)zIxR<9U|mE0%DX8d%tT+rz7~^o| zZ3?`RV=o8Xs9j5DqybM~4oW$GE0Lx%xRj0x+(@@Xp5UEw-h;1a$0RTOB4FMVHdFmf z$`$x{fBtZB{e)YxG)UJCv6Z&#>*_~{`u75-k+6SvyUwNnVHm>S1^9sp20n{pV_HJB zlXgqmBcZXL-I>mw1dBP=)Y2gg7XaEc4Tj;?IF#`Z!EZ=d|Gf{!YI;MKHW`;Jin4~u zIupnl6RXvHg#S7~5Cs2rDN79bGQ(h=$`Zokqj(yJxHdK>`}%cf5d12qfPl^XN2;os i+%!;Cq1pG{;Bc}=b(*TyIR7r~=u