nvmesensor: Introduce nvme-mi-mctp build feature
Allow MCTP support to be configured at build time.
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I280337fce81a24c47bdb3b86279f2664ba80b380
diff --git a/meson_options.txt b/meson_options.txt
index ae88ef3..6bf8530 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,6 +7,7 @@
option('ipmb', type: 'feature', value: 'enabled', description: 'Enable IPMB sensor.',)
option('mcu', type: 'feature', value: 'enabled', description: 'Enable MCU sensor.',)
option('nvme', type: 'feature', value: 'disabled', description: 'Enable NVMe sensor.',)
+option('nvme-mi-mctp', type: 'feature', value: 'enabled', description: 'Manage NVMe devices via MCTP')
option('psu', type: 'feature', value: 'enabled', description: 'Enable PSU sensor.',)
option('external', type: 'feature', value: 'enabled', description: 'Enable External sensor.',)
option('tests', type: 'feature', value: 'enabled', description: 'Build tests.',)
diff --git a/src/NVMeSensorMain.cpp b/src/NVMeSensorMain.cpp
index f1254cb..9c44dee 100644
--- a/src/NVMeSensorMain.cpp
+++ b/src/NVMeSensorMain.cpp
@@ -129,7 +129,11 @@
}
else
{
+#if HAVE_NVME_MI_MCTP
context = std::make_shared<NVMeMCTPContext>(io, rootBus);
+#else
+ context = std::make_shared<NVMeBasicContext>(io, rootBus);
+#endif
nvmeDeviceMap[rootBus] = context;
}
@@ -154,7 +158,9 @@
auto systemBus = std::make_shared<sdbusplus::asio::connection>(io);
systemBus->request_name("xyz.openbmc_project.NVMeSensor");
sdbusplus::asio::object_server objectServer(systemBus);
+#if HAVE_NVME_MI_MCTP
nvmeMCTP::init();
+#endif
io.post([&]() { createSensors(io, objectServer, systemBus); });
diff --git a/src/meson.build b/src/meson.build
index 3475bd5..d2535e2 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -139,10 +139,16 @@
if get_option('nvme').enabled()
nvme_srcs = files('NVMeSensorMain.cpp', 'NVMeSensor.cpp')
nvme_srcs += files('NVMeBasicContext.cpp')
- nvme_srcs += files('NVMeMCTPContext.cpp')
- mctp = meson.get_compiler('cpp').find_library('libmctp')
- nvme_deps = [ default_deps, i2c, mctp, thresholds_dep, utils_dep, threads ]
+ nvme_deps = [ default_deps, i2c, thresholds_dep, utils_dep, threads ]
+
+ mi_mctp = get_option('nvme-mi-mctp')
+ if mi_mctp.enabled()
+ nvme_srcs += files('NVMeMCTPContext.cpp')
+ nvme_deps += meson.get_compiler('cpp').find_library('libmctp')
+ conf_data = configuration_data()
+ conf_data.set('HAVE_NVME_MI_MCTP', true)
+ endif
executable(
'nvmesensor',