-
Notifications
You must be signed in to change notification settings - Fork 20
/
meson.build
390 lines (337 loc) · 13.2 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# Copyright 2020 - 2024, project-repo and the cagebreak contributors
# SPDX-License-Identifier: MIT
project(
'cagebreak',
'c',
version : '2.4.0',
license : 'MIT',
default_options : ['c_std=c23', 'warning_level=3']
)
add_project_arguments(
[
'-DWLR_USE_UNSTABLE',
'-Werror=implicit-function-declaration',
'-Wundef',
],
language: 'c',
)
if get_option('buildtype').startswith('debug')
add_project_arguments(
[
'-DDEBUG',
'-g',
],
language : 'c',
)
endif
cc = meson.get_compiler('c')
fuzz_compile_args = []
fuzz_link_args = []
if get_option('fuzz')
fuzzing_engine = meson.get_compiler('c').find_library('Fuzzer', required : false)
if fuzzing_engine.found()
fuzz_compile_args += '-fsanitize-coverage=trace-pc-guard,trace-cmp'
elif cc.has_argument('-fsanitize=fuzzer-no-link')
fuzz_compile_args += '-fsanitize=fuzzer-no-link'
fuzz_link_args += '-fsanitize=fuzzer-no-link'
else
error('Looks like neither libFuzzer nor -fsanitize=fuzzer-no-link is supported. Disable fuzzing using -Dfuzz=false to build without fuzzers.')
endif
endif
is_freebsd = host_machine.system().startswith('freebsd')
if is_freebsd
add_project_arguments(
[
'-Wno-format-extra-args',
'-Wno-gnu-zero-variadic-macro-arguments',
],
language: 'c'
)
endif
wlroots = dependency('wlroots-0.18')
wayland_protos = dependency('wayland-protocols', version: '>=1.14')
wayland_server = dependency('wayland-server')
wayland_cursor = dependency('wayland-cursor')
wayland_client = dependency('wayland-client')
xkbcommon = dependency('xkbcommon')
cairo = dependency('cairo')
pango = dependency('pango')
pangocairo = dependency('pangocairo')
fontconfig = dependency('fontconfig')
libinput = dependency('libinput')
libevdev = dependency('libevdev')
libudev = dependency('libudev')
math = cc.find_library('m')
wl_protocol_dir = wayland_protos.get_pkgconfig_variable('pkgdatadir')
wayland_scanner = find_program('wayland-scanner')
wayland_scanner_server = generator(
wayland_scanner,
output: '@[email protected]',
arguments: ['server-header', '@INPUT@', '@OUTPUT@'],
)
server_protocols = [
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
]
server_protos_headers = []
foreach p : server_protocols
xml = join_paths(p)
server_protos_headers += wayland_scanner_server.process(xml)
endforeach
server_protos = declare_dependency(
sources: server_protos_headers,
)
if get_option('xwayland')
wlroots_has_xwayland = cc.get_define('WLR_HAS_XWAYLAND', prefix: '#include <wlr/config.h>', dependencies: wlroots) == '1'
if not wlroots_has_xwayland
error('Cannot build Cagebreak with XWayland support: wlroots has been built without it')
else
have_xwayland = true
endif
else
have_xwayland = false
endif
fanalyzer_compile_flag=[]
if cc.has_argument('-fanalyzer')
have_fanalyze=true
fanalyzer_compile_flag=[ '-fanalyzer' ]
else
have_fanalyze=false
endif
if get_option('version_override') != ''
version = '@0@'.format(get_option('version_override'))
else
version = '@0@'.format(meson.project_version())
endif
conf_data = configuration_data()
conf_data.set10('CG_HAS_XWAYLAND', have_xwayland)
conf_data.set10('CG_HAS_FANALYZE', have_fanalyze)
conf_data.set_quoted('CG_VERSION', version)
cagebreak_main_file = [ 'cagebreak.c', ]
cagebreak_source_strings = [
'idle_inhibit_v1.c',
'input_manager.c',
'ipc_server.c',
'keybinding.c',
'workspace.c',
'output.c',
'parse.c',
'seat.c',
'util.c',
'view.c',
'xdg_shell.c',
'libinput.c',
'server.c',
'message.c',
'pango.c',
]
cagebreak_header_strings = [
'idle_inhibit_v1.h',
'ipc_server.h',
'keybinding.h',
'workspace.h',
'output.h',
'parse.h',
'seat.h',
'server.h',
'util.h',
'view.h',
'xdg_shell.h',
'pango.h',
'message.h',
]
if conf_data.get('CG_HAS_XWAYLAND', 0) == 1
cagebreak_source_strings += 'xwayland.c'
cagebreak_header_strings += 'xwayland.h'
endif
cagebreak_sources = [
configure_file(input: 'config.h.in',
output: 'config.h',
configuration: conf_data),
]
cagebreak_headers = []
foreach source : cagebreak_source_strings
cagebreak_sources += files(source)
endforeach
foreach header : cagebreak_header_strings
cagebreak_headers += files(header)
endforeach
# Dependencies marked with "true" are required to have
# the version specified below in order for the build
# to be reproducible.
cagebreak_dependencies_dict = {
'server_protos': [server_protos,true],
'wayland_server': [wayland_server,false],
'wayland_client': [wayland_client,true],
'wayland_cursor': [wayland_cursor,true],
'wlroots': [wlroots,true],
'xkbcommon': [xkbcommon,true],
'fontconfig': [fontconfig,true],
'libinput': [libinput,true],
'libevdev': [libevdev,true],
'libudev': [libudev,true],
'pango': [pango,true],
'cairo': [cairo,true],
'pangocairo': [pangocairo,true],
'math': [math,true],
}
reproducible_build_versions = {
'server_protos': '-1',
'wayland_server': '1.19.0',
'wayland_client': '1.23.1',
'wayland_cursor': '1.23.1',
'wlroots': '0.18.1',
'xkbcommon': '1.7.0',
'fontconfig': '2.15.0',
'libinput': '1.26.2',
'libevdev': '1.13.3',
'libudev': '256',
'pango': '1.54.0',
'cairo': '1.18.2',
'pangocairo': '1.54.0',
'math': '-1'
}
cagebreak_dependencies = []
foreach name, dep : cagebreak_dependencies_dict
cagebreak_dependencies += dep[0]
endforeach
foreach name, dep : cagebreak_dependencies_dict
if reproducible_build_versions[name] != '-1'
if dep[1] == false
if dep[0].version() < reproducible_build_versions[name]
warning('The installed version of "' + name + '" on your machine (' + dep[0].version() + ') is older than the one used to generate the binary specified in Hashes.md (' + reproducible_build_versions[name] + '). It is recommended to use an up-to-date version for compiling cagebreak.'
)
endif
elif reproducible_build_versions[name] != dep[0].version()
warning('The installed version of "' + name + '" on your machine (' + dep[0].version() + ') differs from the one used to generate the binary specified in Hashes.md (' + reproducible_build_versions[name] + '). Cagebreak does not guarantee a reproducible build for this configuration.'
)
break
endif
endif
endforeach
reproducible_build_compiler = 'gcc'
reproducible_build_compiler_version = '14.2.1'
if cc.get_id() != reproducible_build_compiler
warning('The compiler "' + cc.get_id() + '" differs from the one used to generate to binary specified in Hashes.md (' + reproducible_build_compiler + ').')
elif cc.version() != reproducible_build_compiler_version
warning('The version of ' + cc.get_id() + ' (' + cc.version() + ') differs from the one used to generate the binary specified in Hashes.md ' + reproducible_build_compiler_version + '.')
endif
executable(
meson.project_name(),
cagebreak_main_file + cagebreak_sources + cagebreak_headers,
dependencies: cagebreak_dependencies,
install: true,
link_args: fuzz_link_args+fanalyzer_compile_flag,
c_args: fuzz_compile_args,
)
install_data('examples/config', install_dir : '/etc/xdg/cagebreak')
install_data('LICENSE', install_dir : '/usr/share/licenses/' + meson.project_name() + '/')
if get_option('man-pages')
scdoc = find_program('scdoc')
secssinceepoch = 1728318420
shcommand = 'export SOURCE_DATE_EPOCH=' + secssinceepoch.to_string() + ' ; @0@ < @INPUT@'.format(scdoc.path())
sh = find_program('sh')
mandir1 = join_paths(get_option('mandir'), 'man1')
mandir5 = join_paths(get_option('mandir'), 'man5')
mandir7 = join_paths(get_option('mandir'), 'man7')
cagebreak_man = custom_target('cagebreak_man',
output : 'cagebreak.1',
input : 'man/cagebreak.1.md',
capture : true,
command : [sh, '-c', shcommand],
install: true,
install_dir: mandir1
)
cagebreak_man = custom_target('cagebreak_config_man',
output : 'cagebreak-config.5',
input : 'man/cagebreak-config.5.md',
capture : true,
command : [sh, '-c', shcommand],
install: true,
install_dir: mandir5
)
cagebreak_man = custom_target('cagebreak_socket_man',
output : 'cagebreak-socket.7',
input : 'man/cagebreak-socket.7.md',
capture : true,
command : [sh, '-c', shcommand],
install: true,
install_dir: mandir7
)
endif
fuzz_sources = [
'fuzz/fuzz-parse.c',
'fuzz/fuzz-lib.c',
]
fuzz_headers = [
'parse.h',
'fuzz/fuzz-lib.h',
]
fuzz_override_lib = [ 'fuzz/execl_override.c' ]
if get_option('fuzz')
inc = include_directories(['.','build/'])
fuzz_dependencies = cagebreak_dependencies
if fuzzing_engine.found()
fuzz_dependencies += fuzzing_engine
else
link_args = [ '-fsanitize=fuzzer', ]
endif
override_lib = shared_library('execl_override',
[ fuzz_override_lib ],
dependencies: [ cairo,pango,pangocairo ],
install: false
)
executable(
'fuzz-parse',
fuzz_sources + fuzz_headers + cagebreak_headers + cagebreak_sources,
dependencies: fuzz_dependencies,
install: false,
include_directories: inc,
link_args: link_args + fuzz_link_args,
c_args: fuzz_compile_args,
link_with: override_lib,
)
endif
summary = [
'',
'Cagebreak @0@'.format(version),
'',
' xwayland: @0@'.format(have_xwayland),
''
]
message('\n'.join(summary))
run_target('devel-install',
command : ['scripts/install-development-environment'])
run_target('fuzz',
command : ['scripts/fuzz', get_option('corpus')])
run_target('adjust-epoch',
command : ['scripts/adjust-epoch'])
run_target('git-tag',
command : ['scripts/git-tag', get_option('gpg_id'), meson.project_version()])
run_target('output-hashes',
command : ['scripts/output-hashes', meson.project_version()])
run_target('create-sigs',
command : ['scripts/create-signatures', get_option('gpg_id')])
run_target('set-ver',
command : ['scripts/set-version', meson.project_version()])
run_target('create-artefacts',
command : ['scripts/create-release-artefacts', get_option('gpg_id'), meson.project_version()])
# Test Suite
test('Build without warnings', find_program('test/build-w-o-warnings'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
test('Example script header is consistent', find_program('test/script-header'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
test('Script executability is consistent', find_program('test/script-header'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
test('Man page consistency', find_program('test/man-pages'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
test('Build without xwayland', find_program('test/build-w-o-xwayland'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
test('Copyright and LICENSE', find_program('test/copyright-license'), args : [ cagebreak_main_file + cagebreak_source_strings + cagebreak_header_strings + fuzz_sources + fuzz_headers + fuzz_override_lib ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()), ''.join('MESONLICENSE=', meson.project_license())], suite: 'devel' )
test('Formatting check (clang-format)', find_program('test/clang-format'), args : [ cagebreak_main_file + cagebreak_source_strings + cagebreak_header_strings + fuzz_sources + fuzz_headers + fuzz_override_lib ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
test('Script linting (shellcheck)', find_program('test/shellcheck'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
test('GPG key validity', find_program('test/gpg-validity'), args : [ meson.project_version() ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
test('Illegal Strings', find_program('test/illegal-strings'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel')
test('Static analysis (scan-build)', find_program('test/scan-build'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'devel-long')
test('Arguments', find_program('test/arguments'), args : [ meson.project_version() ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'basic')
test('Environment Variables', find_program('test/environment-variables'), env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'basic')
test('Semantic versioning', find_program('test/versions'), args : [ meson.project_version() ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'release')
test('Signature validity', find_program('test/gpg-signatures'), suite: 'release')
test('Hashes.md', find_program('test/hashes-md'), args : [ meson.project_version() ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'release')
test('Non-auto tests', find_program('test/non-auto-tests'), args : [ meson.project_version() ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'release')
test('Git tag', find_program('test/git-tag'), args : [ meson.project_version() ], suite: 'release')
test('Release-artefacts', find_program('test/check-artefacts'), args : [ meson.project_version() ], env : [ ''.join('MESONCURRENTCONFIGDIR=', meson.current_source_dir()) ], suite: 'release')