fsutils: Add TinyCBOR Library
This commit is contained in:
parent
c2f75330f7
commit
98dde40a88
fsutils/libtinycbor
2
fsutils/libtinycbor/.gitignore
vendored
Normal file
2
fsutils/libtinycbor/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/minmea
|
||||
/*.zip
|
17
fsutils/libtinycbor/Kconfig
Normal file
17
fsutils/libtinycbor/Kconfig
Normal file
@ -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
|
24
fsutils/libtinycbor/Make.defs
Normal file
24
fsutils/libtinycbor/Make.defs
Normal file
@ -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
|
64
fsutils/libtinycbor/Makefile
Normal file
64
fsutils/libtinycbor/Makefile
Normal file
@ -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
|
31
fsutils/libtinycbor/fix_open_memstream.patch
Normal file
31
fsutils/libtinycbor/fix_open_memstream.patch
Normal file
@ -0,0 +1,31 @@
|
||||
From a66a373a9417d3f481e9346286d93e33fac8e616 Mon Sep 17 00:00:00 2001
|
||||
From: Lee Lup Yuen <luppy@appkaki.com>
|
||||
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 <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
-#if defined(__unix__) || defined(__APPLE__)
|
||||
+#if defined(__unix__) || defined(__APPLE__) || defined(__NuttX__)
|
||||
# include <unistd.h>
|
||||
#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
|
||||
|
Loading…
x
Reference in New Issue
Block a user