Skip to content

Commit 83a76fd

Browse files
committed
build: initial windows support
Restructure meson.build files to support windows (msys2). This is the first step in the windows port and does not generate a useful executalbe. Signed-off-by: Brandon Capener <[email protected]> remove is_windows and add host_system update want_fabrics
1 parent 5263254 commit 83a76fd

9 files changed

Lines changed: 189 additions & 101 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,5 @@ tests/*.pyc
2323

2424
# Ignore PyPI build artifacts
2525
dist/
26+
27+
.vscode/

libnvme/examples/meson.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
#
66
# Authors: Martin Belanger <[email protected]>
77
#
8+
9+
# Skip examples on Windows for now.
10+
if host_system != 'windows'
11+
812
executable(
913
'telemetry-listen',
1014
['telemetry-listen.c'],
@@ -90,3 +94,5 @@ if libdbus_dep.found()
9094
],
9195
)
9296
endif
97+
98+
endif # host_system != 'windows'

libnvme/src/meson.build

Lines changed: 44 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,27 @@
55
#
66
# Authors: Martin Belanger <[email protected]>
77
#
8-
sources = [
9-
'nvme/accessors.c',
10-
'nvme/base64.c',
11-
'nvme/cmds.c',
12-
'nvme/crc32.c',
13-
'nvme/filters.c',
14-
'nvme/ioctl.c',
15-
'nvme/lib.c',
16-
'nvme/linux.c',
17-
'nvme/log.c',
18-
'nvme/mi-mctp.c',
19-
'nvme/mi.c',
20-
'nvme/sysfs.c',
21-
'nvme/tree.c',
22-
'nvme/util.c',
23-
]
8+
sources = []
9+
if host_system == 'windows'
10+
sources += []
11+
else
12+
sources += [
13+
'nvme/accessors.c',
14+
'nvme/base64.c',
15+
'nvme/cmds.c',
16+
'nvme/crc32.c',
17+
'nvme/filters.c',
18+
'nvme/ioctl.c',
19+
'nvme/lib.c',
20+
'nvme/linux.c',
21+
'nvme/log.c',
22+
'nvme/mi-mctp.c',
23+
'nvme/mi.c',
24+
'nvme/sysfs.c',
25+
'nvme/tree.c',
26+
'nvme/util.c',
27+
]
28+
endif
2429
headers = [
2530
'nvme/accessors.h',
2631
'nvme/cmds.h',
@@ -50,21 +55,32 @@ if liburing_dep.found()
5055
sources += 'nvme/uring.c'
5156
endif
5257

53-
if json_c_dep.found()
54-
sources += 'nvme/json.c'
55-
else
56-
sources += 'nvme/no-json.c'
58+
if host_system != 'windows'
59+
if json_c_dep.found()
60+
sources += 'nvme/json.c'
61+
else
62+
sources += 'nvme/no-json.c'
63+
endif
5764
endif
5865

5966
deps = [
6067
config_dep,
6168
ccan_dep,
6269
json_c_dep,
6370
keyutils_dep,
64-
libdbus_dep,
65-
liburing_dep,
6671
openssl_dep,
72+
accessors_dep,
6773
]
74+
if host_system == 'windows'
75+
deps += [
76+
kernel32_dep
77+
]
78+
else
79+
deps += [
80+
libdbus_dep,
81+
liburing_dep,
82+
]
83+
endif
6884

6985
nvme_ld = meson.current_source_dir() / 'libnvme.ld'
7086
nvmf_ld = meson.current_source_dir() / 'libnvmf.ld'
@@ -74,6 +90,12 @@ link_args = [
7490
'-Wl,--version-script=@0@'.format(nvme_ld),
7591
'-Wl,--version-script=@0@'.format(accessors_ld),
7692
]
93+
# Skipping accessor generation for now on Windows. Needs to be ported.
94+
if host_system != 'windows'
95+
link_args += [
96+
'-Wl,--version-script=@0@'.format(accessors_ld),
97+
]
98+
endif
7799

78100
libconf = configuration_data()
79101
if want_fabrics

libnvme/test/meson.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ endif
2121
# define as meson unit-tests, and therefore get run as part of the 'test'
2222
# target. However, they're available for developer use, when hardware is
2323
# available.
24+
25+
# Skip tests on Windows for now.
26+
if host_system != 'windows'
27+
2428
main = executable(
2529
'main-test',
2630
['test.c'],
@@ -221,3 +225,5 @@ foreach hdr : [
221225
)
222226
test('libnvme - header/' + hdr, exe)
223227
endforeach
228+
229+
endif # host_system != 'windows'

meson.build

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ project(
2323
default_options: [
2424
'c_std=gnu99',
2525
'buildtype=debugoptimized',
26-
'prefix=/usr/local',
2726
'warning_level=1',
2827
'sysconfdir=etc',
2928
'wrap_mode=nofallback',
@@ -34,6 +33,7 @@ fs = import('fs')
3433

3534
cc = meson.get_compiler('c')
3635
cxx_available = add_languages('cpp', required: false, native: false)
36+
host_system = host_machine.system()
3737

3838
################################################################################
3939
# Determine which features we need to build: The nvme executable, the libnvme
@@ -51,7 +51,7 @@ cxx_available = add_languages('cpp', required: false, native: false)
5151
# dependencies are present. Also, -Dpython=enabled forces -Dlibnvme=enabled.
5252
want_nvme = get_option('nvme').disabled() == false
5353
want_libnvme = get_option('libnvme').disabled() == false
54-
want_fabrics = get_option('fabrics').disabled() == false
54+
want_fabrics = get_option('fabrics').disabled() == false and host_system != 'windows'
5555
want_docs = get_option('docs')
5656
want_docs_build = get_option('docs-build')
5757

@@ -131,8 +131,12 @@ conf.set('RUNDIR', '"@0@"'.format(rundir))
131131

132132
conf.set('CONFIG_FABRICS', want_fabrics, description: 'Is fabrics enabled')
133133

134+
if host_system == 'windows'
135+
kernel32_dep = cc.find_library('kernel32', required: true)
136+
endif
137+
134138
# Check for libjson-c availability
135-
if get_option('json-c').disabled()
139+
if host_system == 'windows' or get_option('json-c').disabled()
136140
json_c_dep = dependency('', required: false)
137141
else
138142
json_c_dep = dependency(
@@ -365,7 +369,7 @@ conf.set10(
365369

366370
is_static = get_option('default_library') == 'static'
367371
have_netdb = false
368-
if not is_static
372+
if not is_static and host_system != 'windows'
369373
have_netdb = cc.links(
370374
'''#include <sys/types.h>
371375
#include <sys/socket.h>
@@ -471,18 +475,26 @@ if want_nvme
471475
subdir('plugins') # declares: plugin_sources
472476
subdir('util') # declares: util_sources
473477

474-
sources = [
475-
'libnvme-wrap.c',
476-
'logging.c',
477-
'nvme-cmds.c',
478-
'nvme-models.c',
479-
'nvme-print-binary.c',
480-
'nvme-print-stdout.c',
481-
'nvme-print.c',
482-
'nvme-rpmb.c',
483-
'nvme.c',
484-
'plugin.c',
485-
]
478+
sources = []
479+
if host_system == 'windows'
480+
sources += [
481+
'nvme-dummy.c', # Dummy source file for Windows port bring up.
482+
]
483+
else
484+
sources += [
485+
'libnvme-wrap.c',
486+
'logging.c',
487+
'nvme-cmds.c',
488+
'nvme-models.c',
489+
'nvme-print-binary.c',
490+
'nvme-print-stdout.c',
491+
'nvme-print.c',
492+
'nvme-rpmb.c',
493+
'nvme.c',
494+
'plugin.c',
495+
]
496+
endif
497+
486498
if want_fabrics
487499
sources += 'fabrics.c'
488500
endif
@@ -495,16 +507,27 @@ if want_nvme
495507
sources += plugin_sources
496508
sources += util_sources
497509

510+
link_args_list = []
511+
link_deps = [
512+
config_dep,
513+
ccan_dep,
514+
libnvme_dep,
515+
json_c_dep,
516+
]
517+
518+
if host_system == 'windows'
519+
link_deps += [
520+
kernel32_dep,
521+
]
522+
else
523+
link_args_list = ['-ldl']
524+
endif
525+
498526
executable(
499527
'nvme',
500528
sources,
501-
dependencies: [
502-
config_dep,
503-
ccan_dep,
504-
libnvme_dep,
505-
json_c_dep,
506-
],
507-
link_args: '-ldl',
529+
dependencies: link_deps,
530+
link_args: link_args_list,
508531
install: true,
509532
install_dir: sbindir,
510533
)
@@ -632,6 +655,11 @@ dep_dict = {
632655
'python3': py3_dep.found(),
633656
'liburing': liburing_dep.found(),
634657
}
658+
if host_system == 'windows'
659+
dep_dict += {
660+
'kernel32': kernel32_dep.found(),
661+
}
662+
endif
635663
summary(dep_dict, section: 'Dependencies', bool_yn: true)
636664

637665
wanted_dict = {
@@ -648,4 +676,3 @@ conf_dict = {
648676
'pdc enabled': get_option('pdc-enabled'),
649677
}
650678
summary(conf_dict, section: 'Configuration', bool_yn: true)
651-

nvme-dummy.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
3+
#include <stdio.h>
4+
5+
int main(int argc, char **argv)
6+
{
7+
printf("This is a dummy executable for windows port bring up.\n");
8+
return 0;
9+
}

plugins/meson.build

Lines changed: 47 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
11
# SPDX-License-Identifier: GPL-2.0-or-later
22

33
# 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-
'netapp': ['plugins/netapp/netapp-nvme.c'],
19-
'nvidia': ['plugins/nvidia/nvidia-nvme.c'],
20-
'sandisk': ['plugins/sandisk/sandisk-nvme.c', 'plugins/sandisk/sandisk-utils.c'],
21-
'scaleflux': ['plugins/scaleflux/sfx-nvme.c'],
22-
'seagate': ['plugins/seagate/seagate-nvme.c'],
23-
'shannon': ['plugins/shannon/shannon-nvme.c'],
24-
'ssstc': ['plugins/ssstc/ssstc-nvme.c'],
25-
'toshiba': ['plugins/toshiba/toshiba-nvme.c'],
26-
'transcend': ['plugins/transcend/transcend-nvme.c'],
27-
'virtium': ['plugins/virtium/virtium-nvme.c'],
28-
'wdc': ['plugins/wdc/wdc-nvme.c', 'plugins/wdc/wdc-utils.c'],
29-
'ymtc': ['plugins/ymtc/ymtc-nvme.c'],
30-
'zns': ['plugins/zns/zns.c'],
31-
}
4+
all_plugins = {}
5+
if host_system != 'windows'
6+
all_plugins += {
7+
'amzn': ['plugins/amzn/amzn-nvme.c'],
8+
'dapustor': ['plugins/dapustor/dapustor-nvme.c'],
9+
'dell': ['plugins/dell/dell-nvme.c'],
10+
'dera': ['plugins/dera/dera-nvme.c'],
11+
'fdp': ['plugins/fdp/fdp.c'],
12+
'huawei': ['plugins/huawei/huawei-nvme.c'],
13+
'ibm': ['plugins/ibm/ibm-nvme.c'],
14+
'innogrit': ['plugins/innogrit/innogrit-nvme.c'],
15+
'inspur': ['plugins/inspur/inspur-nvme.c'],
16+
'intel': ['plugins/intel/intel-nvme.c'],
17+
'mangoboost': ['plugins/mangoboost/mangoboost-nvme.c'],
18+
'memblaze': ['plugins/memblaze/memblaze-nvme.c'],
19+
'micron': ['plugins/micron/micron-nvme.c'],
20+
'netapp': ['plugins/netapp/netapp-nvme.c'],
21+
'nvidia': ['plugins/nvidia/nvidia-nvme.c'],
22+
'sandisk': ['plugins/sandisk/sandisk-nvme.c', 'plugins/sandisk/sandisk-utils.c'],
23+
'scaleflux': ['plugins/scaleflux/sfx-nvme.c'],
24+
'seagate': ['plugins/seagate/seagate-nvme.c'],
25+
'shannon': ['plugins/shannon/shannon-nvme.c'],
26+
'ssstc': ['plugins/ssstc/ssstc-nvme.c'],
27+
'toshiba': ['plugins/toshiba/toshiba-nvme.c'],
28+
'transcend': ['plugins/transcend/transcend-nvme.c'],
29+
'virtium': ['plugins/virtium/virtium-nvme.c'],
30+
'wdc': ['plugins/wdc/wdc-nvme.c', 'plugins/wdc/wdc-utils.c'],
31+
'ymtc': ['plugins/ymtc/ymtc-nvme.c'],
32+
'zns': ['plugins/zns/zns.c'],
33+
}
34+
endif
3235

3336
# Get the list of plugins to build
3437
selected_plugins = get_option('plugins')
@@ -46,22 +49,24 @@ if want_fabrics and 'nbft' in selected_plugins
4649
plugin_sources += ['plugins/nbft/nbft-plugin.c']
4750
endif
4851

49-
if 'feat' in selected_plugins
50-
subdir('feat')
51-
endif
52+
if host_system != 'windows'
53+
if 'feat' in selected_plugins
54+
subdir('feat')
55+
endif
5256

53-
if 'lm' in selected_plugins
54-
subdir('lm')
55-
endif
57+
if 'lm' in selected_plugins
58+
subdir('lm')
59+
endif
5660

57-
if 'ocp' in selected_plugins
58-
subdir('ocp')
59-
endif
61+
if 'ocp' in selected_plugins
62+
subdir('ocp')
63+
endif
6064

61-
if 'sed' in selected_plugins and conf.get('HAVE_SED_OPAL') != 0
62-
subdir('sed')
63-
endif
65+
if 'sed' in selected_plugins and conf.get('HAVE_SED_OPAL') != 0
66+
subdir('sed')
67+
endif
6468

65-
if 'solidigm' in selected_plugins and json_c_dep.found()
66-
subdir('solidigm')
69+
if 'solidigm' in selected_plugins and json_c_dep.found()
70+
subdir('solidigm')
71+
endif
6772
endif

0 commit comments

Comments
 (0)