diff --git a/examples/json/Kconfig b/examples/json/Kconfig index bf90ec4c0..5724070cc 100644 --- a/examples/json/Kconfig +++ b/examples/json/Kconfig @@ -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. diff --git a/netutils/cjson/.gitignore b/netutils/cjson/.gitignore new file mode 100644 index 000000000..27e3b2978 --- /dev/null +++ b/netutils/cjson/.gitignore @@ -0,0 +1,3 @@ +/cJSON-* +/v*.tar.gz +/Make.dep diff --git a/netutils/cjson/Kconfig b/netutils/cjson/Kconfig new file mode 100644 index 000000000..39fd80dc0 --- /dev/null +++ b/netutils/cjson/Kconfig @@ -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 diff --git a/netutils/cjson/Make.defs b/netutils/cjson/Make.defs new file mode 100644 index 000000000..ef5eed184 --- /dev/null +++ b/netutils/cjson/Make.defs @@ -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 +# +# 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 + diff --git a/netutils/cjson/Makefile b/netutils/cjson/Makefile new file mode 100644 index 000000000..bc8a801d7 --- /dev/null +++ b/netutils/cjson/Makefile @@ -0,0 +1,95 @@ +############################################################################ +# apps/ netutils/cjson/Makefile +# +# Copyright (C) 2019 Gregory Nutt. All rights reserved. +# Author: Mateusz Szafoni +# +# 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