From 7ca354536d01f9c6489ff334bb2cf1032b6fb7d1 Mon Sep 17 00:00:00 2001 From: Daniel Wagner Date: Mon, 6 Feb 2023 15:04:46 +0100 Subject: [PATCH] build: Make json-c dependency optional again 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 --- meson.build | 13 ++++++++----- meson_options.txt | 1 + src/meson.build | 4 +++- src/nvme/no-json.c | 26 ++++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 6 deletions(-) create mode 100644 src/nvme/no-json.c diff --git a/meson.build b/meson.build index cf72d6d8..b99c069e 100644 --- a/meson.build +++ b/meson.build @@ -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 diff --git a/meson_options.txt b/meson_options.txt index 2c093ca8..f471a885 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -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') diff --git a/src/meson.build b/src/meson.build index 1186e81f..8b382b21 100644 --- a/src/meson.build +++ b/src/meson.build @@ -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 index 00000000..171144ef --- /dev/null +++ b/src/nvme/no-json.c @@ -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 + */ + +#include "tree.h" + +#include + +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; +} -- 2.50.1