You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2024/04/22 13:46:44 UTC

(nuttx-apps) branch master updated: Add support for protocol buffers (nanopb) Adding nanopb download and compilation

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new ad7f69d25 Add support for protocol buffers (nanopb) Adding nanopb download and compilation
ad7f69d25 is described below

commit ad7f69d25e60ff22c0041925b869b80eb17e9adc
Author: Filipe Cavalcanti <fi...@gmail.com>
AuthorDate: Tue Apr 16 15:36:54 2024 -0300

    Add support for protocol buffers (nanopb)
    Adding nanopb download and compilation
    
    Improvements and example running
    
    Working distclean
    
    Check for win/linux/mac
---
 netutils/nanopb/.gitignore |  1 +
 netutils/nanopb/Kconfig    | 38 ++++++++++++++++++++++
 netutils/nanopb/Make.defs  | 23 ++++++++++++++
 netutils/nanopb/Makefile   | 78 ++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 140 insertions(+)

diff --git a/netutils/nanopb/.gitignore b/netutils/nanopb/.gitignore
new file mode 100644
index 000000000..e6b967afd
--- /dev/null
+++ b/netutils/nanopb/.gitignore
@@ -0,0 +1 @@
+nanopb/
\ No newline at end of file
diff --git a/netutils/nanopb/Kconfig b/netutils/nanopb/Kconfig
new file mode 100644
index 000000000..38897b7f6
--- /dev/null
+++ b/netutils/nanopb/Kconfig
@@ -0,0 +1,38 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+config NETUTILS_NANOPB
+	tristate "Nanopb Protocol Buffers"
+	default n
+	---help---
+		Nanopb is a small code-size Protocol Buffers implementation in ansi C.
+		It is especially suitable for use in microcontrollers, but fits any
+		memory restricted system.
+
+if NETUTILS_NANOPB
+
+config NETUTILS_NANOPB_VERSION
+	string "Nanopb Version"
+	default "0.4.8"
+
+config NETUTILS_NANOPB_EXAMPLE
+	tristate "Enable Nanopb example"
+	default n
+	---help---
+		Enable Nanopb simple example
+
+if NETUTILS_NANOPB_EXAMPLE
+
+config NETUTILS_NANOPB_EXAMPLE_PRIORITY
+	int "Task Priority"
+	default 100
+
+config NETUTILS_NANOPB_EXAMPLE_STACKSIZE
+	int "Task stack size"
+	default DEFAULT_TASK_STACKSIZE
+
+endif
+
+endif
diff --git a/netutils/nanopb/Make.defs b/netutils/nanopb/Make.defs
new file mode 100644
index 000000000..6cd3bef26
--- /dev/null
+++ b/netutils/nanopb/Make.defs
@@ -0,0 +1,23 @@
+############################################################################
+# apps/netutils/nanopb/Make.defs
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+ifneq ($(CONFIG_NETUTILS_NANOPB),)
+CONFIGURED_APPS += $(APPDIR)/netutils/nanopb
+endif
diff --git a/netutils/nanopb/Makefile b/netutils/nanopb/Makefile
new file mode 100644
index 000000000..8bc698247
--- /dev/null
+++ b/netutils/nanopb/Makefile
@@ -0,0 +1,78 @@
+############################################################################
+# apps/netutils/nanopb/Makefile
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+include $(APPDIR)/Make.defs
+
+NANOPB_VERSION = $(CONFIG_NETUTILS_NANOPB_VERSION)
+ifeq ($(CONFIG_HOST_WINDOWS),y)
+	NANOPB_NAME = nanopb-$(NANOPB_VERSION)-windows-x86
+else ifeq ($(CONFIG_HOST_LINUX),y)
+	NANOPB_NAME = nanopb-$(NANOPB_VERSION)-linux-x86
+else
+	NANOPB_NAME = nanopb-$(NANOPB_VERSION)-macosx-x86
+endif
+
+NANOPB_TARBALL	= $(NANOPB_NAME).tar.gz
+NANOPB_UNPACK	= nanopb
+NANOPB_SRCDIR	= $(NANOPB_UNPACK)
+
+$(NANOPB_TARBALL):
+	$(Q) echo "Downloading $(NANOPB_TARBALL)"
+	$(Q) curl -O -L https://jpa.kapsi.fi/nanopb/download/$(NANOPB_TARBALL)
+
+$(NANOPB_UNPACK): $(NANOPB_TARBALL)
+	$(Q) tar zxf $(NANOPB_TARBALL)
+	$(Q) mv nanopb-$(NANOPB_VERSION)-linux-x86 $(NANOPB_UNPACK)
+	$(Q) mv $(NANOPB_TARBALL) $(NANOPB_UNPACK)
+
+ifeq ($(wildcard $(NANOPB_UNPACK)),)
+context:: $(NANOPB_UNPACK)
+endif
+
+CSRCS = $(NANOPB_SRCDIR)$(DELIM)pb_common.c
+CSRCS += $(NANOPB_SRCDIR)$(DELIM)pb_decode.c
+CSRCS += $(NANOPB_SRCDIR)$(DELIM)pb_encode.c
+
+ifneq ($(CONFIG_NETUTILS_NANOPB_EXAMPLE),)
+PROGNAME  = nanopb_example
+PRIORITY  = $(CONFIG_NETUTILS_NANOPB_EXAMPLE_PRIORITY)
+STACKSIZE = $(CONFIG_NETUTILS_NANOPB_EXAMPLE_STACKSIZE)
+MODULE    = $(CONFIG_NETUTILS_NANOPB_EXAMPLE)
+
+EXAMPLE_DIR = $(NANOPB_UNPACK)$(DELIM)examples$(DELIM)simple
+MAINSRC = $(EXAMPLE_DIR)$(DELIM)simple.c
+CSRCS += $(EXAMPLE_DIR)$(DELIM)simple.pb.c	
+CFLAGS += "-I$(NANOPB_UNPACK)"
+
+# The context below generates the simple.pb.c and simple.pb.h from the .proto
+# file using the nanobpb_generator executable inside nanopb/generator-bin.
+GENERATOR_EXECUTABLE = $(NANOPB_UNPACK)$(DELIM)generator-bin$(DELIM)nanopb_generator
+ifeq ($(CONFIG_HOST_WINDOWS),y)
+GENERATOR_EXECUTABLE += .exe
+endif
+
+context::
+	$(GENERATOR_EXECUTABLE)	--output-dir=$(EXAMPLE_DIR) --options-path=$(EXAMPLE_DIR) $(EXAMPLE_DIR)$(DELIM)simple.proto
+endif
+
+distclean::
+	$(call DELDIR, $(NANOPB_UNPACK))
+
+include $(APPDIR)/Application.mk