]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
build: Make json-c dependency optional again
authorDaniel Wagner <dwagner@suse.de>
Mon, 6 Feb 2023 14:04:46 +0000 (15:04 +0100)
committerDaniel Wagner <dwagner@suse.de>
Mon, 6 Feb 2023 14:04:46 +0000 (15:04 +0100)
Make support for JSON related functionality optional again. Some
embedded configuration do not want to have a lot of dependencies.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
meson.build
meson_options.txt
src/meson.build
src/nvme/no-json.c [new file with mode: 0644]

index cf72d6d8b1ec3c299624f19c977ff2d7ff2be549..b99c069e5c8643e970acbcb2b2a8ca2830008670 100644 (file)
@@ -50,11 +50,14 @@ conf.set('PROJECT_VERSION', '"@0@"'.format(meson.project_version()))
 
 conf.set('SYSCONFDIR', '"@0@"'.format(sysconfdir))
 
-# Check for json-c availability
-json_c_dep = dependency('json-c',
-                       version: '>=0.13',
-                       required: true,
-                       fallback : ['json-c', 'json_c_dep'])
+if get_option('json-c').disabled()
+    json_c_dep = dependency('', required: false)
+else
+    json_c_dep = dependency('json-c',
+                            version: '>=0.13',
+                            required: true,
+                            fallback : ['json-c', 'json_c_dep'])
+endif
 conf.set('CONFIG_JSONC', json_c_dep.found(), description: 'Is json-c required?')
 
 # Check for OpenSSL availability
index 2c093ca867629a432c83bce48c50101c2c34de86..f471a885a504b6b4bcc3f301cdb595f3a1b0c8f8 100644 (file)
@@ -10,3 +10,4 @@ option('docs-build', type : 'boolean', value : false,  description : 'build docu
 option('python', type : 'combo', choices : ['auto', 'true', 'false'], description : 'Generate libnvme python bindings')
 option('openssl', type : 'feature', value: 'auto', description : 'OpenSSL support')
 option('libdbus', type : 'feature', value: 'auto', description : 'libdbus support')
+option('json-c', type : 'feature', value: 'auto', description : 'JSON support')
index 1186e81f30637796408ac7181cc3a5824e8d86d7..8b382b212e57eaad40a8c2f7485f7cb05fa06634 100644 (file)
@@ -23,8 +23,10 @@ mi_sources = [
     'nvme/mi-mctp.c',
 ]
 
-if conf.get('CONFIG_JSONC')
+if json_c_dep.found()
     sources += 'nvme/json.c'
+else
+    sources += 'nvme/no-json.c'
 endif
 
 deps = [
diff --git a/src/nvme/no-json.c b/src/nvme/no-json.c
new file mode 100644 (file)
index 0000000..171144e
--- /dev/null
@@ -0,0 +1,26 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ * This file is part of libnvme.
+ * Copyright (c) 2023 SUSE Software Solutions
+ *
+ * Authors: Daniel Wagner <dwagner@suse.de>
+ */
+
+#include "tree.h"
+
+#include <errno.h>
+
+int json_read_config(nvme_root_t r, const char *config_file)
+{
+       return -ENOTSUP;
+}
+
+int json_update_config(nvme_root_t r, const char *config_file)
+{
+       return -ENOTSUP;
+}
+
+int json_dump_tree(nvme_root_t r)
+{
+       return -ENOTSUP;
+}