From b09264cad63c0e91234cd3f5da74d648249accd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20R=C3=A1bek?= Date: Mon, 9 Mar 2026 20:01:10 +0100 Subject: [PATCH] build: add an option to specify a list of plugins to include MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, nvme-cli builds with all available plugins. However, there are some users who are not intersted in some particular plugins or they aim to create the smallest binaries possible. This patch introduces that feature into the nvme-cli's build system. Closes: #2907 Signed-off-by: Michal Rábek --- Makefile | 14 +++++-- README.md | 21 +++++++++- meson_options.txt | 11 +++++ plugins/meson.build | 99 +++++++++++++++++++++++++++------------------ 4 files changed, 100 insertions(+), 45 deletions(-) diff --git a/Makefile b/Makefile index 489426d242..18ee7d6e63 100644 --- a/Makefile +++ b/Makefile @@ -9,12 +9,17 @@ NAME := nvme .DEFAULT_GOAL := ${NAME} BUILD-DIR := .build +# Allow PLUGINS variable as a shorthand for MESON_ARGS +ifdef PLUGINS + MESON_ARGS += -Dplugins=$(PLUGINS) +endif + .PHONY: update-subprojects update-subprojects: meson subprojects update ${BUILD-DIR}: - meson setup $@ + meson setup $@ ${MESON_ARGS} @echo "Configuration located in: $@" @echo "-------------------------------------------------------" @@ -55,7 +60,7 @@ test-strict: ${NAME} .PHONY: rpm rpm: - meson setup ${BUILD-DIR} \ + meson setup ${BUILD-DIR} ${MESON_ARGS} \ -Dudevrulesdir=$(shell rpm --eval '%{_udevrulesdir}') \ -Dsystemddir=$(shell rpm --eval '%{_unitdir}') \ -Ddocs=man -Ddocs-build=true @@ -63,12 +68,13 @@ rpm: .PHONY: debug debug: - meson setup ${BUILD-DIR} --buildtype=debug + meson setup ${BUILD-DIR} ${MESON_ARGS} --buildtype=debug meson compile -C ${BUILD-DIR} .PHONY: static static: - meson setup ${BUILD-DIR} --buildtype=release \ + meson setup ${BUILD-DIR} ${MESON_ARGS} + --buildtype=release \ --wrap-mode=forcefallback \ --default-library=static \ --prefix=/usr \ diff --git a/README.md b/README.md index 46baa3a260..a9f2d4d3d2 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,26 @@ If not sure how to use, find the top-level documentation with: Or find a short summary with: $ nvme help - + +### Building with specific plugins + +By default, all vendor plugins are built. To build only specific plugins, use the `plugins` option: + + $ meson setup .build -Dplugins=intel,wdc,ocp + $ meson compile -C .build + +Or with the Makefile wrapper: + + $ make PLUGINS="intel,wdc,ocp" + +When `PLUGINS` is not used, the value defaults to `all`, which selects all plugins: + + $ make PLUGINS="all" + +To build without any vendor plugins: + + $ make PLUGINS="" + ## Distro Support Many popular distributions (Alpine, Arch, Debian, Fedora, FreeBSD, Gentoo, diff --git a/meson_options.txt b/meson_options.txt index d6f858e566..6fd51daf77 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -142,3 +142,14 @@ option( value : false, description : 'building for PyPI (use short soversion, e.g. libnvme.so.3)' ) +option( + 'plugins', + type : 'array', + choices: ['amzn', 'dapustor', 'dell', 'dera', + 'fdp', 'feat', 'huawei', 'ibm', 'innogrit', 'inspur', 'intel', + 'lm', 'mangoboost', 'memblaze', 'micron', 'nbft', + 'netapp', 'nvidia', 'ocp', 'sandisk', 'scaleflux', + 'seagate', 'sed', 'shannon', 'solidigm', 'ssstc', 'toshiba', + 'transcend', 'virtium', 'wdc', 'ymtc', 'zns'], + description : 'comma-separated list of plugins to build (all plugins are included if unset, [] = no plugins)' +) diff --git a/plugins/meson.build b/plugins/meson.build index 8def5651f6..63014b667a 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -1,45 +1,64 @@ # SPDX-License-Identifier: GPL-2.0-or-later -plugin_sources = [ - 'plugins/amzn/amzn-nvme.c', - 'plugins/dapustor/dapustor-nvme.c', - 'plugins/dell/dell-nvme.c', - 'plugins/dera/dera-nvme.c', - 'plugins/fdp/fdp.c', - 'plugins/huawei/huawei-nvme.c', - 'plugins/ibm/ibm-nvme.c', - 'plugins/innogrit/innogrit-nvme.c', - 'plugins/inspur/inspur-nvme.c', - 'plugins/intel/intel-nvme.c', - 'plugins/mangoboost/mangoboost-nvme.c', - 'plugins/memblaze/memblaze-nvme.c', - 'plugins/micron/micron-nvme.c', - 'plugins/nbft/nbft-plugin.c', - 'plugins/netapp/netapp-nvme.c', - 'plugins/nvidia/nvidia-nvme.c', - 'plugins/sandisk/sandisk-nvme.c', - 'plugins/sandisk/sandisk-utils.c', - 'plugins/scaleflux/sfx-nvme.c', - 'plugins/seagate/seagate-nvme.c', - 'plugins/shannon/shannon-nvme.c', - 'plugins/ssstc/ssstc-nvme.c', - 'plugins/toshiba/toshiba-nvme.c', - 'plugins/transcend/transcend-nvme.c', - 'plugins/virtium/virtium-nvme.c', - 'plugins/wdc/wdc-nvme.c', - 'plugins/wdc/wdc-utils.c', - 'plugins/ymtc/ymtc-nvme.c', - 'plugins/zns/zns.c', -] - -subdir('feat') -subdir('lm') -subdir('ocp') - -if conf.get('HAVE_SED_OPAL') != 0 - subdir('sed') +# Define all available plugins and their source files +all_plugins = { + 'amzn': ['plugins/amzn/amzn-nvme.c'], + 'dapustor': ['plugins/dapustor/dapustor-nvme.c'], + 'dell': ['plugins/dell/dell-nvme.c'], + 'dera': ['plugins/dera/dera-nvme.c'], + 'fdp': ['plugins/fdp/fdp.c'], + 'huawei': ['plugins/huawei/huawei-nvme.c'], + 'ibm': ['plugins/ibm/ibm-nvme.c'], + 'innogrit': ['plugins/innogrit/innogrit-nvme.c'], + 'inspur': ['plugins/inspur/inspur-nvme.c'], + 'intel': ['plugins/intel/intel-nvme.c'], + 'mangoboost': ['plugins/mangoboost/mangoboost-nvme.c'], + 'memblaze': ['plugins/memblaze/memblaze-nvme.c'], + 'micron': ['plugins/micron/micron-nvme.c'], + 'nbft': ['plugins/nbft/nbft-plugin.c'], + 'netapp': ['plugins/netapp/netapp-nvme.c'], + 'nvidia': ['plugins/nvidia/nvidia-nvme.c'], + 'sandisk': ['plugins/sandisk/sandisk-nvme.c', 'plugins/sandisk/sandisk-utils.c'], + 'scaleflux': ['plugins/scaleflux/sfx-nvme.c'], + 'seagate': ['plugins/seagate/seagate-nvme.c'], + 'shannon': ['plugins/shannon/shannon-nvme.c'], + 'ssstc': ['plugins/ssstc/ssstc-nvme.c'], + 'toshiba': ['plugins/toshiba/toshiba-nvme.c'], + 'transcend': ['plugins/transcend/transcend-nvme.c'], + 'virtium': ['plugins/virtium/virtium-nvme.c'], + 'wdc': ['plugins/wdc/wdc-nvme.c', 'plugins/wdc/wdc-utils.c'], + 'ymtc': ['plugins/ymtc/ymtc-nvme.c'], + 'zns': ['plugins/zns/zns.c'], +} + +# Get the list of plugins to build +selected_plugins = get_option('plugins') + +# Build the plugin_sources list from simple plugins +plugin_sources = [] +foreach plugin_name : selected_plugins + plugin_name_stripped = plugin_name.strip() + if plugin_name_stripped in all_plugins + plugin_sources += all_plugins[plugin_name_stripped] + endif +endforeach + +if 'feat' in selected_plugins + subdir('feat') +endif + +if 'lm' in selected_plugins + subdir('lm') +endif + +if 'ocp' in selected_plugins + subdir('ocp') +endif + +if 'sed' in selected_plugins and conf.get('HAVE_SED_OPAL') != 0 + subdir('sed') endif -if json_c_dep.found() - subdir('solidigm') +if 'solidigm' in selected_plugins and json_c_dep.found() + subdir('solidigm') endif