Skip to content

Commit 3d467eb

Browse files
bcapenerigaw
authored andcommitted
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]> [wagi: moved host_system condition up] Signed-off-by: Daniel Wagner <[email protected]>
1 parent f28da7e commit 3d467eb

7 files changed

Lines changed: 138 additions & 67 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/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ if want_libnvme
3434
subdir('tools/generator') # generate code needed by src below
3535
subdir('src') # declares: libnvme_dep
3636
subdir('libnvme')
37-
if get_option('tests')
37+
if want_tests
3838
subdir('test')
3939
endif
40-
if get_option('examples')
40+
if want_examples
4141
subdir('examples')
4242
endif
4343

libnvme/src/meson.build

Lines changed: 37 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,31 @@ 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,
6772
]
73+
if host_system == 'windows'
74+
deps += [
75+
kernel32_dep
76+
]
77+
else
78+
deps += [
79+
libdbus_dep,
80+
liburing_dep,
81+
]
82+
endif
6883

6984
nvme_ld = meson.current_source_dir() / 'libnvme.ld'
7085
nvmf_ld = meson.current_source_dir() / 'libnvmf.ld'

meson.build

Lines changed: 64 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ fs = import('fs')
3434

3535
cc = meson.get_compiler('c')
3636
cxx_available = add_languages('cpp', required: false, native: false)
37+
host_system = host_machine.system()
3738

3839
################################################################################
3940
# Determine which features we need to build: The nvme executable, the libnvme
@@ -51,10 +52,15 @@ cxx_available = add_languages('cpp', required: false, native: false)
5152
# dependencies are present. Also, -Dpython=enabled forces -Dlibnvme=enabled.
5253
want_nvme = get_option('nvme').disabled() == false
5354
want_libnvme = get_option('libnvme').disabled() == false
54-
want_fabrics = get_option('fabrics').disabled() == false
55+
want_fabrics = get_option('fabrics').disabled() == false and host_system != 'windows'
56+
want_json_c = get_option('json-c').disabled() == false and host_system != 'windows'
57+
want_tests = get_option('tests') and host_system != 'windows'
58+
want_examples = get_option('examples') and host_system != 'windows'
5559
want_docs = get_option('docs')
5660
want_docs_build = get_option('docs-build')
5761

62+
is_static = get_option('default_library') == 'static' and host_system != 'windows'
63+
5864
feature_python = get_option('python')
5965
if not want_fabrics or feature_python.disabled()
6066
py3_dep = dependency('', required: false) # Needed for muon
@@ -131,8 +137,12 @@ conf.set('RUNDIR', '"@0@"'.format(rundir))
131137

132138
conf.set('CONFIG_FABRICS', want_fabrics, description: 'Is fabrics enabled')
133139

140+
if host_system == 'windows'
141+
kernel32_dep = cc.find_library('kernel32', required: true)
142+
endif
143+
134144
# Check for libjson-c availability
135-
if get_option('json-c').disabled()
145+
if want_json_c
136146
json_c_dep = dependency('', required: false)
137147
else
138148
json_c_dep = dependency(
@@ -363,7 +373,6 @@ conf.set10(
363373
description: 'Is linux/mctp.h include-able?'
364374
)
365375

366-
is_static = get_option('default_library') == 'static'
367376
have_netdb = false
368377
if not is_static
369378
have_netdb = cc.links(
@@ -473,45 +482,67 @@ if want_nvme
473482
subdir('plugins') # declares: plugin_sources
474483
subdir('util') # declares: util_sources
475484

476-
sources = [
477-
'libnvme-wrap.c',
478-
'logging.c',
479-
'nvme-cmds.c',
480-
'nvme-models.c',
481-
'nvme-print-binary.c',
482-
'nvme-print-stdout.c',
483-
'nvme-print.c',
484-
'nvme-rpmb.c',
485-
'nvme.c',
486-
'plugin.c',
487-
]
485+
sources = []
486+
if host_system == 'windows'
487+
sources += [
488+
'nvme-dummy.c', # Dummy source file for Windows port bring up.
489+
]
490+
else
491+
sources += [
492+
'libnvme-wrap.c',
493+
'logging.c',
494+
'nvme-cmds.c',
495+
'nvme-models.c',
496+
'nvme-print-binary.c',
497+
'nvme-print-stdout.c',
498+
'nvme-print.c',
499+
'nvme-rpmb.c',
500+
'nvme.c',
501+
'plugin.c',
502+
]
503+
504+
if json_c_dep.found()
505+
sources += [
506+
'nvme-print-json.c',
507+
]
508+
endif
509+
endif
510+
488511
if want_fabrics
489512
sources += 'fabrics.c'
490513
endif
491514

492-
if json_c_dep.found()
493-
sources += [
494-
'nvme-print-json.c',
495-
]
496-
endif
497515
sources += plugin_sources
498516
sources += util_sources
499517

518+
link_args_list = []
519+
link_deps = [
520+
config_dep,
521+
ccan_dep,
522+
libnvme_dep,
523+
json_c_dep,
524+
]
525+
526+
if host_system == 'windows'
527+
link_deps += [
528+
kernel32_dep,
529+
]
530+
else
531+
link_args_list = ['-ldl']
532+
endif
533+
500534
executable(
501535
'nvme',
502536
sources,
503-
dependencies: [
504-
config_dep,
505-
ccan_dep,
506-
libnvme_dep,
507-
json_c_dep,
508-
],
509-
link_args: '-ldl',
537+
dependencies: link_deps,
538+
link_args: link_args_list,
510539
install: true,
511540
install_dir: sbindir,
512541
)
513542

514-
subdir('unit')
543+
if host_system != 'windows'
544+
subdir('unit')
545+
endif
515546
if get_option('nvme-tests')
516547
subdir('tests')
517548
endif
@@ -645,6 +676,11 @@ dep_dict = {
645676
'python3': py3_dep.found(),
646677
'liburing': liburing_dep.found(),
647678
}
679+
if host_system == 'windows'
680+
dep_dict += {
681+
'kernel32': kernel32_dep.found(),
682+
}
683+
endif
648684
summary(dep_dict, section: 'Dependencies', bool_yn: true)
649685

650686
wanted_dict = {
@@ -661,4 +697,3 @@ conf_dict = {
661697
'pdc enabled': get_option('pdc-enabled'),
662698
}
663699
summary(conf_dict, section: 'Configuration', bool_yn: true)
664-

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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ all_plugins = {
3131
}
3232

3333
# Get the list of plugins to build
34-
selected_plugins = get_option('plugins')
34+
if host_system != 'windows'
35+
selected_plugins = get_option('plugins')
36+
else
37+
selected_plugins = []
38+
endif
3539

3640
# Build the plugin_sources list from simple plugins
3741
plugin_sources = []

util/meson.build

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,25 @@
11
# SPDX-License-Identifier: GPL-2.0-or-later
22

3-
util_sources = [
4-
'util/argconfig.c',
5-
'util/base64.c',
6-
'util/crc32.c',
7-
'util/mem.c',
8-
'util/sighdl.c',
9-
'util/suffix.c',
10-
'util/types.c',
11-
'util/utils.c',
12-
'util/table.c'
13-
]
3+
util_sources = []
144

15-
if json_c_dep.found()
5+
if host_system == 'windows'
6+
util_sources += []
7+
else
168
util_sources += [
17-
'util/json.c',
9+
'util/argconfig.c',
10+
'util/base64.c',
11+
'util/crc32.c',
12+
'util/mem.c',
13+
'util/sighdl.c',
14+
'util/suffix.c',
15+
'util/types.c',
16+
'util/utils.c',
17+
'util/table.c'
1818
]
19+
20+
if json_c_dep.found()
21+
util_sources += [
22+
'util/json.c',
23+
]
24+
endif
1925
endif

0 commit comments

Comments
 (0)