Skip to content

Commit 609e6fa

Browse files
authored
Merge pull request #185 from martin-belanger/ccan-static-lib
Define ccan as a static library
2 parents 014c8e9 + 0827e06 commit 609e6fa

6 files changed

Lines changed: 44 additions & 15 deletions

File tree

ccan/meson.build

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@
66
# Authors: Martin Belanger <[email protected]>
77
#
88

9-
sources += files([
9+
sources = [
1010
'ccan/list/list.c',
1111
'ccan/str/debug.c',
1212
'ccan/str/str.c',
13-
])
13+
]
1414

1515
if get_option('buildtype') == 'debug'
1616
add_project_arguments('-DCCAN_LIST_DEBUG=1', language : ['c', 'cpp'])
1717
add_project_arguments('-DCCAN_STR_DEBUG=1', language : ['c', 'cpp'])
1818
endif
19+
20+
libccan = static_library(
21+
'ccan',
22+
sources,
23+
install: false,
24+
include_directories: [incdir, internal_incdir],
25+
dependencies: config_dep,
26+
)

examples/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,3 @@ executable(
2525
link_with: libnvme,
2626
include_directories: [incdir, internal_incdir]
2727
)
28-

internal/meson.build

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
#
3+
# This file is part of libnvme.
4+
# Copyright (c) 2022 Dell Inc.
5+
#
6+
# Authors: Martin Belanger <[email protected]>
7+
#
8+
# Because libnvme is used as a subproject of nvme-cli,
9+
# the config.h file must be generated as a private file
10+
# hidden from nvme-cli.
11+
12+
config_h = configure_file(
13+
output: 'config.h',
14+
configuration: conf
15+
)
16+
17+
internal_incdir = include_directories('.')
18+
19+
config_dep = declare_dependency(
20+
include_directories : internal_incdir,
21+
sources: config_h)

libnvme/meson.build

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
#
66
# Authors: Martin Belanger <[email protected]>
77
#
8-
configure_file(
9-
output: 'config.h',
10-
configuration: conf
11-
)
12-
138
want_python = get_option('python')
149
if want_python != 'false'
1510
python3 = import('python').find_installation('python3')
@@ -35,8 +30,8 @@ if have_python_support
3530
'_nvme',
3631
pymod_swig[1],
3732
dependencies : py3_dep,
38-
include_directories: incdir,
39-
link_with: libnvme,
33+
include_directories: [incdir, internal_incdir],
34+
link_with: [libnvme, libccan],
4035
install: true,
4136
subdir: 'libnvme',
4237
)

meson.build

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,18 @@ configure_file(
150150
)
151151

152152
################################################################################
153-
add_project_arguments(['-fomit-frame-pointer', '-D_GNU_SOURCE',
154-
'-include', 'libnvme/config.h'], language : 'c')
153+
add_project_arguments(
154+
[
155+
'-fomit-frame-pointer',
156+
'-D_GNU_SOURCE',
157+
'-include', 'internal/config.h',
158+
],
159+
language : 'c',
160+
)
155161
incdir = include_directories(['.', 'ccan', 'src'])
156-
internal_incdir = include_directories('libnvme')
157162

158163
################################################################################
159-
sources = []
164+
subdir('internal')
160165
subdir('ccan')
161166
subdir('src')
162167
subdir('libnvme')

src/meson.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#
66
# Authors: Martin Belanger <[email protected]>
77
#
8-
sources += [
8+
sources = [
99
'nvme/cleanup.c',
1010
'nvme/fabrics.c',
1111
'nvme/filters.c',
@@ -39,6 +39,7 @@ libnvme = library(
3939
link_depends: mapfile,
4040
include_directories: [incdir, internal_incdir],
4141
install: true,
42+
link_with: libccan,
4243
)
4344

4445
pkg = import('pkgconfig')

0 commit comments

Comments
 (0)