-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmeson.build
123 lines (111 loc) · 3.06 KB
/
meson.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
project('tbtree', 'c',
version: '1.0.0',
license: 'UNLICENSE',
default_options: [
'buildtype=debugoptimized',
'default_library=static',
'c_std=c11',
'werror=true',
'warning_level=2',
]
)
project_source_root = meson.current_source_dir()
project_build_root = meson.current_build_dir()
install_headers('src/tbtree.h')
if get_option('tests')
cc = meson.get_compiler('c')
cflags = [
'-D_GNU_SOURCE',
'-D_LARGE_FILES',
'-D_LARGEFILE_SOURCE',
'-D_FILE_OFFSET_BITS=64',
'-D_TIME_BITS=64',
]
cflags_check = [
'-pipe',
'-funwind-tables',
'-fno-common',
'-Wfatal-errors',
'-Wundef',
'-pedantic',
'-pedantic-errors',
'-Wstrict-prototypes',
'-Wmissing-prototypes',
'-Wmissing-declarations',
'-Wno-missing-field-initializers',
'-Wno-unused-parameter',
'-Wduplicated-branches',
'-Wduplicated-cond',
'-Wimplicit-fallthrough',
'-Wdouble-promotion',
'-Wpointer-arith',
'-Wfloat-equal',
'-Wlogical-op',
'-Wshadow',
'-Wvla',
'-Walloca',
'-Wc++-compat',
'-Wformat=2',
'-Wformat-overflow=2',
'-Wformat-truncation=2',
'-Wformat-signedness',
'-Wno-format-pedantic',
'-Wno-format-nonliteral',
'-Wno-clobbered',
'-Wno-strict-aliasing',
]
if cc.get_id() == 'clang'
cflags_check += [
'-Wno-gnu',
'-Wno-builtin-requires-header',
'-Wno-missing-braces',
]
endif
if cc.get_id() == 'gcc' and get_option('analyzer')
cflags_check += '-fanalyzer'
cflags_check += [
'-Wno-analyzer-malloc-leak',
'-Wno-analyzer-null-dereference',
]
if cc.version().version_compare('<12')
cflags_check += '-Wno-analyzer-mismatching-deallocation'
endif
endif
add_project_arguments(
cflags,
cc.get_supported_arguments(cflags_check),
language: 'c'
)
tbtree_test = executable('tbtree_test', 'src/tbtree_test.c',
install: false,
)
if get_option('valgrind')
valgrind = find_program('valgrind', required: true)
valgrind_args = [
'--tool=memcheck',
'--leak-check=full',
'--show-leak-kinds=all',
'--track-fds=no',
'--track-origins=yes',
'--trace-children=yes',
'--error-exitcode=1',
]
test('tbtree_test', valgrind, args: [valgrind_args, tbtree_test])
else
test('tbtree_test', tbtree_test)
endif
endif
astyle = find_program('astyle', required: false)
if astyle.found()
custom_target('astyle',
output: 'astyle',
command: [
astyle,
'--options=@0@/.astylerc'.format(project_source_root),
'-Q', '-n', '-r',
project_source_root / 'src/*.c',
project_source_root / 'src/*.h',
],
console: true,
)
endif