Skip to content

Commit f463756

Browse files
author
Martin Belanger
committed
libnvme/accessors: Add framework to generate accessor code
This only adds the framework for code generation but leaves the actual generation disabled for now. Signed-off-by: Martin Belanger <[email protected]>
1 parent fab8f5e commit f463756

6 files changed

Lines changed: 2103 additions & 0 deletions

File tree

libnvme/meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,8 @@ conf.set(
238238
description: 'Is network address and service translation available'
239239
)
240240

241+
conf.set('NVME_HAVE_SENDFILE', cc.has_function('sendfile'))
242+
241243
threads_dep = dependency('threads', required: true)
242244
dl_dep = dependency('dl', required: false)
243245
conf.set(
@@ -293,6 +295,7 @@ incdir = include_directories(['.', 'ccan', 'src'])
293295
################################################################################
294296
subdir('internal')
295297
subdir('ccan')
298+
#subdir('tools')
296299
subdir('src')
297300
subdir('libnvme')
298301
if get_option('tests')

libnvme/src/generated/meson.build

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
#
3+
# This file is part of libnvme.
4+
# Copyright (c) 2025, Dell Technologies Inc. or its subsidiaries.
5+
#
6+
# Authors: Martin Belanger <[email protected]>
7+
#
8+
# Run generate-accessors to generate the setter/getter functions.
9+
10+
# List of header files to parse for structs
11+
headers_to_scan = [
12+
'../nvme/private.h',
13+
]
14+
15+
# Append full path to each member of headers_to_scan
16+
headers_to_scan_full_path = []
17+
foreach hdr : headers_to_scan
18+
headers_to_scan_full_path += join_paths(meson.current_source_dir(), hdr)
19+
endforeach
20+
21+
# Generate accessors.c and accessors.h
22+
accessors_ch_custom_tgt = custom_target(
23+
'accessors.[ch]',
24+
input: headers_to_scan_full_path,
25+
output: [
26+
'accessors.h',
27+
'accessors.c',
28+
],
29+
command: [
30+
generate_accessors,
31+
'--h-out', '@OUTPUT0@',
32+
'--c-out', '@OUTPUT1@',
33+
'--incl', join_paths(meson.current_source_dir(), 'structs-to-include.txt'),
34+
'@INPUT@',
35+
],
36+
build_by_default: true,
37+
install: true,
38+
install_dir: [
39+
'nvme', # Install @OUTPUT0@=='accessors.h' in this directory.
40+
false, # Do not install @OUTPUT1@=='accessors.c'
41+
],
42+
install_mode: ['rw-r--r--', 0, 0],
43+
)
44+
45+
generated_accessors_h = accessors_ch_custom_tgt[0]
46+
generated_accessors_c = accessors_ch_custom_tgt[1]
47+
48+
if meson.version().version_compare('>=1.4.0')
49+
generated_accessors_h_path = generated_accessors_h.full_path()
50+
else
51+
generated_accessors_h_path = meson.current_build_dir() / 'accessor.h'
52+
endif
53+
54+
generated_accessors_dep = declare_dependency(
55+
sources: [
56+
accessors_ch_custom_tgt,
57+
]
58+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
nvme_path
2+
nvme_ns
3+
nvme_ctrl
4+
nvme_subsystem
5+
nvme_host
6+
nvme_fabric_options

0 commit comments

Comments
 (0)