Skip to content

Commit 692e8b2

Browse files
committed
build: add an option to specify a list of plugins to include
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 <[email protected]>
1 parent bd159e1 commit 692e8b2

4 files changed

Lines changed: 114 additions & 45 deletions

File tree

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,17 @@ NAME := nvme
99
.DEFAULT_GOAL := ${NAME}
1010
BUILD-DIR := .build
1111

12+
# Allow PLUGINS variable as a shorthand for MESON_ARGS
13+
ifdef PLUGINS
14+
MESON_ARGS += -Dplugins=$(PLUGINS)
15+
endif
16+
1217
.PHONY: update-subprojects
1318
update-subprojects:
1419
meson subprojects update
1520

1621
${BUILD-DIR}:
17-
meson setup $@
22+
meson setup $@ ${MESON_ARGS}
1823
@echo "Configuration located in: $@"
1924
@echo "-------------------------------------------------------"
2025

@@ -55,20 +60,21 @@ test-strict: ${NAME}
5560

5661
.PHONY: rpm
5762
rpm:
58-
meson setup ${BUILD-DIR} \
63+
meson setup ${BUILD-DIR} ${MESON_ARGS} \
5964
-Dudevrulesdir=$(shell rpm --eval '%{_udevrulesdir}') \
6065
-Dsystemddir=$(shell rpm --eval '%{_unitdir}') \
6166
-Ddocs=man -Ddocs-build=true
6267
rpmbuild -ba ${BUILD-DIR}/nvme.spec --define "_builddir ${BUILD-DIR}" -v
6368

6469
.PHONY: debug
6570
debug:
66-
meson setup ${BUILD-DIR} --buildtype=debug
71+
meson setup ${BUILD-DIR} ${MESON_ARGS} --buildtype=debug
6772
meson compile -C ${BUILD-DIR}
6873

6974
.PHONY: static
7075
static:
71-
meson setup ${BUILD-DIR} --buildtype=release \
76+
meson setup ${BUILD-DIR} ${MESON_ARGS}
77+
--buildtype=release \
7278
--wrap-mode=forcefallback \
7379
--default-library=static \
7480
--prefix=/usr \

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,26 @@ If not sure how to use, find the top-level documentation with:
113113
Or find a short summary with:
114114

115115
$ nvme help
116-
116+
117+
### Building with specific plugins
118+
119+
By default, all vendor plugins are built. To build only specific plugins, use the `plugins` option:
120+
121+
$ meson setup .build -Dplugins=intel,wdc,ocp
122+
$ meson compile -C .build
123+
124+
Or with the Makefile wrapper:
125+
126+
$ make PLUGINS="intel,wdc,ocp"
127+
128+
When `PLUGINS` is not used, the value defaults to `all`, which selects all plugins:
129+
130+
$ make PLUGINS="all"
131+
132+
To build without any vendor plugins:
133+
134+
$ make PLUGINS=""
135+
117136
## Distro Support
118137

119138
Many popular distributions (Alpine, Arch, Debian, Fedora, FreeBSD, Gentoo,

meson_options.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,9 @@ option(
142142
value : false,
143143
description : 'building for PyPI (use short soversion, e.g. libnvme.so.3)'
144144
)
145+
option(
146+
'plugins',
147+
type : 'string',
148+
value : 'all',
149+
description : 'comma-separated list of plugins to build ("all" or unset = all plugins, "" = no plugins)'
150+
)

plugins/meson.build

Lines changed: 78 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,83 @@
11
# SPDX-License-Identifier: GPL-2.0-or-later
22

3-
plugin_sources = [
4-
'plugins/amzn/amzn-nvme.c',
5-
'plugins/dapustor/dapustor-nvme.c',
6-
'plugins/dell/dell-nvme.c',
7-
'plugins/dera/dera-nvme.c',
8-
'plugins/fdp/fdp.c',
9-
'plugins/huawei/huawei-nvme.c',
10-
'plugins/ibm/ibm-nvme.c',
11-
'plugins/innogrit/innogrit-nvme.c',
12-
'plugins/inspur/inspur-nvme.c',
13-
'plugins/intel/intel-nvme.c',
14-
'plugins/mangoboost/mangoboost-nvme.c',
15-
'plugins/memblaze/memblaze-nvme.c',
16-
'plugins/micron/micron-nvme.c',
17-
'plugins/nbft/nbft-plugin.c',
18-
'plugins/netapp/netapp-nvme.c',
19-
'plugins/nvidia/nvidia-nvme.c',
20-
'plugins/sandisk/sandisk-nvme.c',
21-
'plugins/sandisk/sandisk-utils.c',
22-
'plugins/scaleflux/sfx-nvme.c',
23-
'plugins/seagate/seagate-nvme.c',
24-
'plugins/shannon/shannon-nvme.c',
25-
'plugins/ssstc/ssstc-nvme.c',
26-
'plugins/toshiba/toshiba-nvme.c',
27-
'plugins/transcend/transcend-nvme.c',
28-
'plugins/virtium/virtium-nvme.c',
29-
'plugins/wdc/wdc-nvme.c',
30-
'plugins/wdc/wdc-utils.c',
31-
'plugins/ymtc/ymtc-nvme.c',
32-
'plugins/zns/zns.c',
33-
]
34-
35-
subdir('feat')
36-
subdir('lm')
37-
subdir('ocp')
38-
39-
if conf.get('HAVE_SED_OPAL') != 0
40-
subdir('sed')
3+
# Define all available plugins and their source files
4+
all_plugins = {
5+
'amzn': ['plugins/amzn/amzn-nvme.c'],
6+
'dapustor': ['plugins/dapustor/dapustor-nvme.c'],
7+
'dell': ['plugins/dell/dell-nvme.c'],
8+
'dera': ['plugins/dera/dera-nvme.c'],
9+
'fdp': ['plugins/fdp/fdp.c'],
10+
'huawei': ['plugins/huawei/huawei-nvme.c'],
11+
'ibm': ['plugins/ibm/ibm-nvme.c'],
12+
'innogrit': ['plugins/innogrit/innogrit-nvme.c'],
13+
'inspur': ['plugins/inspur/inspur-nvme.c'],
14+
'intel': ['plugins/intel/intel-nvme.c'],
15+
'mangoboost': ['plugins/mangoboost/mangoboost-nvme.c'],
16+
'memblaze': ['plugins/memblaze/memblaze-nvme.c'],
17+
'micron': ['plugins/micron/micron-nvme.c'],
18+
'nbft': ['plugins/nbft/nbft-plugin.c'],
19+
'netapp': ['plugins/netapp/netapp-nvme.c'],
20+
'nvidia': ['plugins/nvidia/nvidia-nvme.c'],
21+
'sandisk': ['plugins/sandisk/sandisk-nvme.c', 'plugins/sandisk/sandisk-utils.c'],
22+
'scaleflux': ['plugins/scaleflux/sfx-nvme.c'],
23+
'seagate': ['plugins/seagate/seagate-nvme.c'],
24+
'shannon': ['plugins/shannon/shannon-nvme.c'],
25+
'ssstc': ['plugins/ssstc/ssstc-nvme.c'],
26+
'toshiba': ['plugins/toshiba/toshiba-nvme.c'],
27+
'transcend': ['plugins/transcend/transcend-nvme.c'],
28+
'virtium': ['plugins/virtium/virtium-nvme.c'],
29+
'wdc': ['plugins/wdc/wdc-nvme.c', 'plugins/wdc/wdc-utils.c'],
30+
'ymtc': ['plugins/ymtc/ymtc-nvme.c'],
31+
'zns': ['plugins/zns/zns.c'],
32+
}
33+
34+
# Get the list of plugins to build
35+
plugins_option = get_option('plugins').strip()
36+
37+
if plugins_option == ''
38+
# Build no plugins when explicitly set to empty
39+
selected_plugins = []
40+
build_all = false
41+
elif plugins_option == 'all'
42+
# Build all plugins (default)
43+
selected_plugins = all_plugins.keys()
44+
build_all = true
45+
else
46+
# Build only specified plugins
47+
selected_plugins = plugins_option.split(',')
48+
build_all = false
49+
endif
50+
51+
# Build the plugin_sources list from simple plugins
52+
plugin_sources = []
53+
foreach plugin_name : selected_plugins
54+
plugin_name_stripped = plugin_name.strip()
55+
if plugin_name_stripped in all_plugins
56+
plugin_sources += all_plugins[plugin_name_stripped]
57+
elif plugin_name_stripped != ''
58+
# Only warn if it's not a special plugin handled below
59+
if plugin_name_stripped not in ['feat', 'lm', 'ocp', 'sed', 'solidigm']
60+
warning('Unknown plugin: @0@'.format(plugin_name_stripped))
61+
endif
62+
endif
63+
endforeach
64+
65+
if build_all or 'feat' in selected_plugins
66+
subdir('feat')
67+
endif
68+
69+
if build_all or 'lm' in selected_plugins
70+
subdir('lm')
71+
endif
72+
73+
if build_all or 'ocp' in selected_plugins
74+
subdir('ocp')
75+
endif
76+
77+
if (build_all or 'sed' in selected_plugins) and conf.get('HAVE_SED_OPAL') != 0
78+
subdir('sed')
4179
endif
4280

43-
if json_c_dep.found()
44-
subdir('solidigm')
81+
if (build_all or 'solidigm' in selected_plugins) and json_c_dep.found()
82+
subdir('solidigm')
4583
endif

0 commit comments

Comments
 (0)