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 0000000000..d8ed6a5343 --- /dev/null +++ b/pkg/nanopb/patches/0001-generator-nanopb_generator.py-use-python3.patch @@ -0,0 +1,22 @@ +From 416436502170cfd77d19c6e967cc79267b4513d6 Mon Sep 17 00:00:00 2001 +From: Kaspar Schleiser +Date: Sat, 12 Oct 2019 00:26:19 +0200 +Subject: [PATCH] generator/nanopb_generator.py: use python3 + +--- + generator/nanopb_generator.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py +index 03f41a0..4f0ab47 100755 +--- a/generator/nanopb_generator.py ++++ b/generator/nanopb_generator.py +@@ -1,4 +1,4 @@ +-#!/usr/bin/env python ++#!/usr/bin/env python3 + + from __future__ import unicode_literals + +-- +2.23.0 +