From 1263a38038eb2aeb765f8af52b31add9b120ddaf Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Thu, 28 Nov 2019 16:15:50 +0300 Subject: [PATCH 1/2] jsmn configuration added --- components/jsmn/Kconfig | 16 ++++++++++++++++ components/jsmn/include/jsmn.h | 3 +++ 2 files changed, 19 insertions(+) create mode 100644 components/jsmn/Kconfig diff --git a/components/jsmn/Kconfig b/components/jsmn/Kconfig new file mode 100644 index 000000000..114fbe42b --- /dev/null +++ b/components/jsmn/Kconfig @@ -0,0 +1,16 @@ +menu "jsmn" + + + config JSMN_PARENT_LINKS + bool "Enable parent links" + default n + help + You can access to parent node of parsed json + + config JSMN_STRICT + bool "Enable strict mode" + default n + help + In strict mode primitives are: numbers and booleans + +endmenu diff --git a/components/jsmn/include/jsmn.h b/components/jsmn/include/jsmn.h index 1df808e39..73ef95799 100644 --- a/components/jsmn/include/jsmn.h +++ b/components/jsmn/include/jsmn.h @@ -37,6 +37,9 @@ extern "C" { #endif +#define JSMN_PARENT_LINKS CONFIG_JSMN_PARENT_LINKS +#define JSMN_STRICT CONFIG_JSMN_STRICT + /** * JSON type identifier. Basic types are: * o Object From 68dc6b215836860f24c1a1be27fe3c9212856a16 Mon Sep 17 00:00:00 2001 From: morris Date: Fri, 29 Nov 2019 18:05:24 +0800 Subject: [PATCH 2/2] jsmn: define macros in build system --- components/jsmn/CMakeLists.txt | 8 ++++++++ components/jsmn/component.mk | 8 ++++++++ components/jsmn/include/jsmn.h | 3 --- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/components/jsmn/CMakeLists.txt b/components/jsmn/CMakeLists.txt index 0c7a0ab99..d05badb21 100644 --- a/components/jsmn/CMakeLists.txt +++ b/components/jsmn/CMakeLists.txt @@ -1,2 +1,10 @@ idf_component_register(SRCS "src/jsmn.c" INCLUDE_DIRS "include") + +if(CONFIG_JSMN_PARENT_LINKS) + target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DJSMN_PARENT_LINKS") +endif() + +if(CONFIG_JSMN_STRICT) + target_compile_definitions(${COMPONENT_LIB} PUBLIC "-DJSMN_STRICT") +endif() diff --git a/components/jsmn/component.mk b/components/jsmn/component.mk index 96190be50..88f1a9564 100644 --- a/components/jsmn/component.mk +++ b/components/jsmn/component.mk @@ -4,3 +4,11 @@ COMPONENT_ADD_INCLUDEDIRS := include/ COMPONENT_SRCDIRS := src/ + +ifdef CONFIG_JSMN_PARENT_LINKS +src/jsmn.o: CPPFLAGS += -DJSMN_PARENT_LINKS +endif + +ifdef CONFIG_JSMN_STRICT +src/jsmn.o: CPPFLAGS += -DJSMN_STRICT +endif diff --git a/components/jsmn/include/jsmn.h b/components/jsmn/include/jsmn.h index 73ef95799..1df808e39 100644 --- a/components/jsmn/include/jsmn.h +++ b/components/jsmn/include/jsmn.h @@ -37,9 +37,6 @@ extern "C" { #endif -#define JSMN_PARENT_LINKS CONFIG_JSMN_PARENT_LINKS -#define JSMN_STRICT CONFIG_JSMN_STRICT - /** * JSON type identifier. Basic types are: * o Object