diff --git a/fsutils/libtinycbor/.gitignore b/fsutils/libtinycbor/.gitignore new file mode 100644 index 000000000..89885ca8a --- /dev/null +++ b/fsutils/libtinycbor/.gitignore @@ -0,0 +1,2 @@ +/minmea +/*.zip diff --git a/fsutils/libtinycbor/Kconfig b/fsutils/libtinycbor/Kconfig new file mode 100644 index 000000000..e9f865e25 --- /dev/null +++ b/fsutils/libtinycbor/Kconfig @@ -0,0 +1,17 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config FSUTILS_TINYCBOR_LIB + bool "TinyCBOR Library (RFC 8949)" + default n + depends on ALLOW_MIT_COMPONENTS + ---help--- + Enable support for the TinyCBOR library. This is an + implementation of RFC-8949 (Concise Binary Object + Representation). + More info: https://lupyuen.github.io/articles/cbor2 + +if FSUTILS_TINYCBOR_LIB +endif diff --git a/fsutils/libtinycbor/Make.defs b/fsutils/libtinycbor/Make.defs new file mode 100644 index 000000000..2fb9975e4 --- /dev/null +++ b/fsutils/libtinycbor/Make.defs @@ -0,0 +1,24 @@ +############################################################################ +# apps/fsutils/libtinycbor/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_FSUTILS_TINYCBOR_LIB),) +CONFIGURED_APPS += $(APPDIR)/fsutils/libtinycbor +CFLAGS += ${INCDIR_PREFIX}$(APPDIR)/fsutils/libtinycbor +endif diff --git a/fsutils/libtinycbor/Makefile b/fsutils/libtinycbor/Makefile new file mode 100644 index 000000000..14a3d2f0f --- /dev/null +++ b/fsutils/libtinycbor/Makefile @@ -0,0 +1,64 @@ +############################################################################ +# apps/fsutils/libtinycbor/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 + +TINYCBOR_URL ?= "https://github.com/intel/tinycbor/archive" +TINYCBOR_VERSION ?= 3cba6b11aaa0f6f674cd56ebaa573c4b65f71ee7 + +TINYCBOR_UNPACKNAME = tinycbor + +$(TINYCBOR_UNPACKNAME): + @echo "Downloading: $(TINYCBOR_UNPACKNAME)" + $(Q) curl -O -L $(TINYCBOR_URL)/$(TINYCBOR_VERSION).zip + $(Q) mkdir $(TINYCBOR_UNPACKNAME) + $(Q) unzip -o -j $(TINYCBOR_VERSION).zip -d $(TINYCBOR_UNPACKNAME) + $(Q) patch -Np1 < fix_open_memstream.patch + $(call DELFILE, $(TINYCBOR_VERSION).zip) + +# Files + +CSRCS += tinycbor/cborencoder.c +CSRCS += tinycbor/cborencoder_close_container_checked.c +CSRCS += tinycbor/cborencoder_float.c +CSRCS += tinycbor/cborerrorstrings.c +CSRCS += tinycbor/cborparser.c +CSRCS += tinycbor/cborparser_dup_string.c +CSRCS += tinycbor/cborparser_float.c +CSRCS += tinycbor/cborpretty.c +CSRCS += tinycbor/cborpretty_stdio.c +CSRCS += tinycbor/cbortojson.c +CSRCS += tinycbor/cborvalidation.c +CSRCS += tinycbor/open_memstream.c + +CFLAGS += -std=c99 + +clean:: + $(call DELFILE, $(OBJS)) + +# Download and unpack tarball if no git repo found +ifeq ($(wildcard $(TINYCBOR_UNPACKNAME)/.git),) +context:: $(TINYCBOR_UNPACKNAME) + +distclean:: + $(call DELDIR, $(TINYCBOR_UNPACKNAME)) +endif + +include $(APPDIR)/Application.mk diff --git a/fsutils/libtinycbor/fix_open_memstream.patch b/fsutils/libtinycbor/fix_open_memstream.patch new file mode 100644 index 000000000..031f3d2c1 --- /dev/null +++ b/fsutils/libtinycbor/fix_open_memstream.patch @@ -0,0 +1,31 @@ +From a66a373a9417d3f481e9346286d93e33fac8e616 Mon Sep 17 00:00:00 2001 +From: Lee Lup Yuen +Date: Wed, 5 Jan 2022 08:32:38 +0800 +Subject: [PATCH] Fix open_memstream.c compilation + +diff --git a/tinycbor/open_memstream.c b/tinycbor/open_memstream.c +index 3365378..37a0d08 100644 +--- a/tinycbor/open_memstream.c ++++ b/tinycbor/open_memstream.c +@@ -32,7 +32,7 @@ + #include + #include + +-#if defined(__unix__) || defined(__APPLE__) ++#if defined(__unix__) || defined(__APPLE__) || defined(__NuttX__) + # include + #endif + #ifdef __APPLE__ +@@ -41,6 +41,9 @@ typedef int LenType; + #elif __linux__ + typedef ssize_t RetType; + typedef size_t LenType; ++#elif __NuttX__ ++typedef ssize_t RetType; ++typedef size_t LenType; + #else + # error "Cannot implement open_memstream!" + #endif +-- +2.34.1 +