-
Notifications
You must be signed in to change notification settings - Fork 0
/
meson.build
198 lines (174 loc) · 4.21 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# This file is part of the Ssstr string library.
# Copyright 2022-2023 Board of Regents of the University of Wisconsin System
# SPDX-License-Identifier: MIT
project(
'ssstr',
'c',
'cpp',
version: '0.1.1-dev',
license: 'MIT',
meson_version: '>=0.62.0',
default_options: [
'c_std=c99',
'cpp_std=c++11', # Supports c++03 but va_list functions require 11+
'warning_level=3',
'werror=true',
'c_args=-DUNITY_USE_FLUSH_STDOUT', # Doesn't work as subproject default
],
)
cc = meson.get_compiler('c')
if cc.get_id() in ['gcc', 'clang']
extra_args = ['-Wconversion', '-Wshadow']
else
extra_args = []
endif
# MinGW GCC 12 reports warnings that appear to be spurious. Disable only for 12
# because these _may_ go away in GCC 13
# (https://github.com/msys2/MINGW-packages/issues/13104).
if host_machine.system() == 'windows' and cc.get_id() == 'gcc'
if cc.version().startswith('12.')
extra_args += ['-Wno-array-bounds', '-Wno-stringop-overflow']
endif
endif
python_for_tests = find_program(
'python3',
'python',
required: get_option('test'),
disabler: true,
)
python_for_docs = find_program(
'python3',
'python',
required: get_option('docs'),
disabler: true,
)
public_inc = include_directories('include')
public_headers = files(
'include/ss8str.h',
)
version_check_script = files(
'scripts/checkversion.py',
)
test(
'version-check',
python_for_tests,
args: [
version_check_script,
meson.project_version(),
public_headers,
],
)
install_headers(public_headers)
# Meson 'dependency' for use as subproject
ssstr_dep = declare_dependency(
include_directories: public_inc,
)
meson.override_dependency('ssstr', ssstr_dep)
pkgconfig = import('pkgconfig')
pkgconfig.generate(
filebase: 'ssstr',
name: 'ssstr',
description: 'Ssstr small-string-optimized string library',
)
if find_program('cmake', required: false).found()
cmake = import('cmake')
cmake.write_basic_package_version_file(
name: 'Ssstr',
version: meson.project_version(),
arch_independent: true,
)
cmake.configure_package_config_file(
name: 'Ssstr',
input: 'SsstrConfig.cmake.in',
configuration: configuration_data(),
)
endif
unity_dep = dependency('unity', required: get_option('test'), disabler: true)
google_benchmark_dep = dependency(
'benchmark',
required: get_option('benchmark'),
disabler: true,
fallback: 'google-benchmark',
default_options: [
'werror=false',
],
)
subdir('tests')
subdir('examples')
subdir('man')
man_pages_check_script = files('scripts/checkmanpages.py')
if not get_option('docs').disabled()
test(
'man-pages-check',
python_for_tests,
args: [
man_pages_check_script,
public_headers,
example_test_sources,
'--',
man3_pages,
man3_links,
man7_pages,
man7_links,
],
)
endif
groff_prog = find_program(
'groff',
required: get_option('docs'),
disabler: true,
)
htmlman_script = files('scripts/htmlman.py')
htmlman = custom_target(
build_always_stale: true, # Since we cannot list output files
output: 'htmlman',
input: [
man3_pages,
man3_links,
man7_pages,
man7_links,
],
command: [
python_for_docs,
htmlman_script,
'@OUTPUT@',
groff_prog,
'@INPUT@',
],
)
readme_check_script = files(
'scripts/checkreadme.py',
)
readme = files(
'README.md',
)
readme_snippet_test_source = custom_target(
build_by_default: true,
output: 'test_readme_snippets.c',
input: [
readme,
man3_pages,
man3_links,
],
command: [
python_for_tests,
readme_check_script,
'@OUTPUT@',
'@INPUT@',
],
)
readme_snippet_test = executable(
'test_readme_snippets',
readme_snippet_test_source,
c_args: [
extra_args,
'-UNDEBUG',
'-DSSSTR_EXTRA_DEBUG',
'-D_CRT_SECURE_NO_WARNINGS',
],
dependencies: [
ssstr_dep,
unity_dep,
],
)
test('readme-snippet-test', readme_snippet_test)