Skip to content

Commit fe0d6bd

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]>
1 parent 69347e1 commit fe0d6bd

10 files changed

Lines changed: 252 additions & 163 deletions

File tree

.gitignore

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

2222
# Ignore PyPI build artifacts
2323
dist/
24+
25+
.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 not is_windows
11+
812
executable(
913
'telemetry-listen',
1014
['telemetry-listen.c'],
@@ -88,3 +92,5 @@ if libdbus_dep.found()
8892
],
8993
)
9094
endif
95+
96+
endif # not is_windows

libnvme/src/meson.build

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,33 @@
55
#
66
# Authors: Martin Belanger <[email protected]>
77
#
8-
sources = [
9-
'nvme/base64.c',
10-
'nvme/cmds.c',
11-
'nvme/crc32.c',
12-
'nvme/fabrics.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/nbft.c',
21-
'nvme/sysfs.c',
22-
'nvme/tree.c',
23-
'nvme/util.c',
24-
]
25-
26-
if json_c_dep.found()
27-
sources += 'nvme/json.c'
8+
sources = []
9+
if is_windows
10+
sources += []
2811
else
29-
sources += 'nvme/no-json.c'
12+
sources += [
13+
'nvme/base64.c',
14+
'nvme/cmds.c',
15+
'nvme/crc32.c',
16+
'nvme/fabrics.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/nbft.c',
25+
'nvme/sysfs.c',
26+
'nvme/tree.c',
27+
'nvme/util.c',
28+
]
29+
30+
if json_c_dep.found()
31+
sources += 'nvme/json.c'
32+
else
33+
sources += 'nvme/no-json.c'
34+
endif
3035
endif
3136

3237
# Generate accessors (setter/getter functions)
@@ -37,22 +42,37 @@ deps = [
3742
ccan_dep,
3843
json_c_dep,
3944
keyutils_dep,
40-
libdbus_dep,
41-
liburing_dep,
4245
openssl_dep,
4346
accessors_dep,
4447
]
48+
if is_windows
49+
deps += [
50+
kernel32_dep
51+
]
52+
else
53+
deps += [
54+
libdbus_dep,
55+
liburing_dep,
56+
]
57+
endif
4558

4659
ldfile = 'libnvme.ld'
4760

61+
libnvme_link_args = [
62+
'-Wl,--version-script=@0@'.format(meson.current_source_dir() / ldfile),
63+
]
64+
# Skipping accessor generation for now on Windows. Needs to be ported.
65+
if not is_windows
66+
libnvme_link_args += [
67+
'-Wl,--version-script=@0@'.format(accessors_ld_full_path),
68+
]
69+
endif
70+
4871
libnvme = library(
4972
'nvme', # produces libnvme.so
5073
sources,
5174
version: libnvme_so_version,
52-
link_args: [
53-
'-Wl,--version-script=@0@'.format(meson.current_source_dir() / ldfile),
54-
'-Wl,--version-script=@0@'.format(accessors_ld_full_path),
55-
],
75+
link_args: libnvme_link_args,
5676
dependencies: deps,
5777
install: true,
5878
)

libnvme/src/nvme/meson.build

Lines changed: 62 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -7,67 +7,72 @@
77
#
88
# Run generate-accessors to generate the setter/getter functions.
99

10-
generated_h = 'accessors.h'
11-
generated_c = 'accessors.c'
12-
generated_ld = 'accessors.ld'
10+
if is_windows
11+
# Skip for now on Windows. Accessor generation needs to be ported.
12+
accessors_dep = dependency('', required: false)
13+
else
14+
generated_h = 'accessors.h'
15+
generated_c = 'accessors.c'
16+
generated_ld = 'accessors.ld'
1317

14-
# List of header files to parse for structs
15-
headers_to_scan = [
16-
'../nvme/private.h',
17-
]
18+
# List of header files to parse for structs
19+
headers_to_scan = [
20+
'../nvme/private.h',
21+
]
1822

19-
# Build the code generator tool
20-
generate_accessors = executable(
21-
'generate-accessors',
22-
'generate-accessors.c',
23-
c_args: ['-D_GNU_SOURCE'],
24-
dependencies: [
25-
config_dep,
26-
],
27-
native: true,
28-
)
23+
# Build the code generator tool
24+
generate_accessors = executable(
25+
'generate-accessors',
26+
'generate-accessors.c',
27+
c_args: ['-D_GNU_SOURCE'],
28+
dependencies: [
29+
config_dep,
30+
],
31+
native: true,
32+
)
2933

30-
# Generate accessors code
31-
accessors_ch_custom_tgt = custom_target(
32-
'accessors[.c.h.ld]',
33-
input: files(headers_to_scan),
34-
output: [
35-
generated_h,
36-
generated_c,
37-
generated_ld,
38-
],
39-
command: [
40-
generate_accessors,
41-
'--h-out', '@OUTPUT0@',
42-
'--c-out', '@OUTPUT1@',
43-
'--ld-out', '@OUTPUT2@',
44-
'--incl', join_paths(meson.current_source_dir(), 'structs-to-include.txt'),
45-
'@INPUT@',
46-
],
47-
build_by_default: true,
48-
install: true,
49-
install_dir: [
50-
get_option('includedir') / 'nvme',
51-
false,
52-
false,
53-
],
54-
install_mode: 'rw-r--r--',
55-
)
34+
# Generate accessors code
35+
accessors_ch_custom_tgt = custom_target(
36+
'accessors[.c.h.ld]',
37+
input: files(headers_to_scan),
38+
output: [
39+
generated_h,
40+
generated_c,
41+
generated_ld,
42+
],
43+
command: [
44+
generate_accessors,
45+
'--h-out', '@OUTPUT0@',
46+
'--c-out', '@OUTPUT1@',
47+
'--ld-out', '@OUTPUT2@',
48+
'--incl', join_paths(meson.current_source_dir(), 'structs-to-include.txt'),
49+
'@INPUT@',
50+
],
51+
build_by_default: true,
52+
install: true,
53+
install_dir: [
54+
get_option('includedir') / 'nvme',
55+
false,
56+
false,
57+
],
58+
install_mode: 'rw-r--r--',
59+
)
5660

57-
tgt_accessors_h = accessors_ch_custom_tgt[0]
58-
tgt_accessors_c = accessors_ch_custom_tgt[1]
59-
tgt_accessors_ld = accessors_ch_custom_tgt[2]
61+
tgt_accessors_h = accessors_ch_custom_tgt[0]
62+
tgt_accessors_c = accessors_ch_custom_tgt[1]
63+
tgt_accessors_ld = accessors_ch_custom_tgt[2]
6064

61-
accessors_dep = declare_dependency(
62-
sources: [
63-
tgt_accessors_c,
64-
tgt_accessors_h,
65-
],
66-
include_directories: '.',
67-
)
65+
accessors_dep = declare_dependency(
66+
sources: [
67+
tgt_accessors_c,
68+
tgt_accessors_h,
69+
],
70+
include_directories: '.',
71+
)
6872

69-
if meson.version().version_compare('>=1.4.0')
70-
accessors_ld_full_path = tgt_accessors_ld.full_path()
71-
else
72-
accessors_ld_full_path = meson.current_build_dir() / generated_ld
73+
if meson.version().version_compare('>=1.4.0')
74+
accessors_ld_full_path = tgt_accessors_ld.full_path()
75+
else
76+
accessors_ld_full_path = meson.current_build_dir() / generated_ld
77+
endif
7378
endif

libnvme/test/meson.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
# define as meson unit-tests, and therefore get run as part of the 'test'
1010
# target. However, they're available for developer use, when hardware is
1111
# available.
12+
13+
# Skip tests on Windows for now.
14+
if not is_windows
15+
1216
main = executable(
1317
'main-test',
1418
['test.c'],
@@ -205,3 +209,5 @@ foreach hdr : [
205209
)
206210
test('libnvme - header/' + hdr, exe)
207211
endforeach
212+
213+
endif # not is_windows

0 commit comments

Comments
 (0)