Skip to content

Commit b09264c

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 b09264c

4 files changed

Lines changed: 100 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: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,3 +142,14 @@ option(
142142
value : false,
143143
description : 'building for PyPI (use short soversion, e.g. libnvme.so.3)'
144144
)
145+
option(
146+
'plugins',
147+
type : 'array',
148+
choices: ['amzn', 'dapustor', 'dell', 'dera',
149+
'fdp', 'feat', 'huawei', 'ibm', 'innogrit', 'inspur', 'intel',
150+
'lm', 'mangoboost', 'memblaze', 'micron', 'nbft',
151+
'netapp', 'nvidia', 'ocp', 'sandisk', 'scaleflux',
152+
'seagate', 'sed', 'shannon', 'solidigm', 'ssstc', 'toshiba',
153+
'transcend', 'virtium', 'wdc', 'ymtc', 'zns'],
154+
description : 'comma-separated list of plugins to build (all plugins are included if unset, [] = no plugins)'
155+
)

plugins/meson.build

Lines changed: 59 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,64 @@
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+
selected_plugins = get_option('plugins')
36+
37+
# Build the plugin_sources list from simple plugins
38+
plugin_sources = []
39+
foreach plugin_name : selected_plugins
40+
plugin_name_stripped = plugin_name.strip()
41+
if plugin_name_stripped in all_plugins
42+
plugin_sources += all_plugins[plugin_name_stripped]
43+
endif
44+
endforeach
45+
46+
if 'feat' in selected_plugins
47+
subdir('feat')
48+
endif
49+
50+
if 'lm' in selected_plugins
51+
subdir('lm')
52+
endif
53+
54+
if 'ocp' in selected_plugins
55+
subdir('ocp')
56+
endif
57+
58+
if 'sed' in selected_plugins and conf.get('HAVE_SED_OPAL') != 0
59+
subdir('sed')
4160
endif
4261

43-
if json_c_dep.found()
44-
subdir('solidigm')
62+
if 'solidigm' in selected_plugins and json_c_dep.found()
63+
subdir('solidigm')
4564
endif

0 commit comments

Comments
 (0)