Merged in raiden00/apps/cjson (pull request #175)

netutils: support for the current version of cJSON

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
raiden00pl 2019-04-28 12:34:20 +00:00 committed by Gregory Nutt
parent 0a6726bc3e
commit 75aca388a4
5 changed files with 160 additions and 1 deletions

View File

@ -6,7 +6,7 @@
config EXAMPLES_JSON
tristate "JSON example"
default n
select NETUTILS_JSON
depends on NETUTILS_CJSON || NETUTILS_JSON
---help---
An example for the netutils/json library.

3
netutils/cjson/.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/cJSON-*
/v*.tar.gz
/Make.dep

22
netutils/cjson/Kconfig Normal file
View File

@ -0,0 +1,22 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config NETUTILS_CJSON
bool "cJSON library (current version)"
default n
---help---
Enables the cJSON library.
if NETUTILS_CJSON
config NETUTILS_CJSON_URL
string "URL where cJSON library can be downloaded"
default "https://github.com/DaveGamble/cJSON/archive"
config NETUTILS_CJSON_VERSION
string "Version number"
default "1.7.11"
endif

39
netutils/cjson/Make.defs Normal file
View File

@ -0,0 +1,39 @@
# apps/netutils/cjson/Make.defs
# Adds selected applications to apps/ build
#
# Copyright (C) 2019 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
ifeq ($(CONFIG_NETUTILS_CJSON),y)
CONFIGURED_APPS += netutils/cjson
endif

95
netutils/cjson/Makefile Normal file
View File

@ -0,0 +1,95 @@
############################################################################
# apps/ netutils/cjson/Makefile
#
# Copyright (C) 2019 Gregory Nutt. All rights reserved.
# Author: Mateusz Szafoni <raiden00@railab.me>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name NuttX nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
###########################################################################
# Standard includes
-include $(TOPDIR)/Make.defs
# Set up build configuration and environment
WD := ${shell pwd | sed -e 's/ /\\ /g'}
CONFIG_NETUTILS_CJSON_URL ?= "https://github.com/DaveGamble/cJSON/archive"
CONFIG_NETUTILS_CJSON_VERSION ?= "1.7.10"
CJSON_VERSION = $(patsubst "%",%,$(strip $(CONFIG_NETUTILS_CJSON_VERSION)))
CJSON_TARBALL = v$(CJSON_VERSION).tar.gz
WGET ?= wget
CJSON_UNPACKNAME = cJSON-$(CJSON_VERSION)
UNPACK ?= tar -zxf
CJSON_UNPACKDIR = $(WD)/$(CJSON_UNPACKNAME)
CJSON_SRCDIR = $(CJSON_UNPACKDIR)
APPS_INCDIR = $(APPDIR)$(DELIM)include$(DELIM)netutils
CFLAGS += -I$(APPS_INCDIR) -DCJSON_INCLUDE_CONFIG_H
CSRCS = $(CJSON_SRCDIR)$(DELIM)cJSON.c
CSRCS += $(CJSON_SRCDIR)$(DELIM)cJSON_Utils.c
$(CJSON_TARBALL):
@echo "Downloading: $(CJSON_TARBALL)"
$(Q) $(WGET) $(CONFIG_NETUTILS_CJSON_URL)/$(CJSON_TARBALL)
$(CJSON_UNPACKNAME): $(CJSON_TARBALL)
@echo "Unpacking: $(CJSON_TARBALL) -> $(CJSON_UNPACKNAME)"
$(Q) $(UNPACK) $(CJSON_TARBALL)
@touch $(CJSON_UNPACKNAME)
$(CJSON_SRCDIR)$(DELIM)cJSON.h: $(CJSON_UNPACKNAME)
$(CJSON_SRCDIR)$(DELIM)cJSON_Utils.h: $(CJSON_UNPACKNAME)
$(APPS_INCDIR)$(DELIM)cJSON.h: $(CJSON_SRCDIR)$(DELIM)cJSON.h
$(Q) cp $< $@
$(APPS_INCDIR)$(DELIM)cJSON_Utils.h: $(CJSON_SRCDIR)$(DELIM)cJSON_Utils.h
$(Q) cp $< $@
context:: $(APPS_INCDIR)$(DELIM)cJSON.h $(APPS_INCDIR)$(DELIM)cJSON_Utils.h
clean::
$(call DELDIR, build)
distclean::
$(call DELDIR, $(CJSON_UNPACKNAME))
$(call DELFILE, .downloaded)
$(call DELFILE, $(CJSON_TARBALL))
$(call DELFILE, $(APPDIR)/include/netutils/cJSON.h)
$(call DELFILE, $(APPDIR)/include/netutils/cJSON_Utils.h)
include $(APPDIR)/Application.mk