build: Allow specifying --werror build option

meson has a builtin -werror option that can be passed to meson setup. So
as to allow users to specify if they want to treat warnings as errors,
let's add this flag to meson.build.

We elect to make the flag the default behavior for now, as warnings in
BPF scheds are not surfaced unless there is an actual compiler error.
The warning can be turned off by specifying `-D werror=false` when
invoking `meson setup`.

Signed-off-by: David Vernet <void@manifault.com>
This commit is contained in:
David Vernet 2024-05-17 21:38:27 -05:00
parent b421cee59e
commit 4a88008cbe
No known key found for this signature in database
GPG Key ID: 59E4B86965C4F364

View File

@ -1,6 +1,7 @@
project('sched_ext schedulers', 'c',
version: '0.1.9',
license: 'GPL-2.0')
license: 'GPL-2.0',
default_options: 'werror=true',)
if meson.version().version_compare('<1.2')
error('meson >= 1.2 required')
@ -234,6 +235,10 @@ bpf_base_cflags = ['-g', '-O2', '-Wall', '-Wno-compare-distinct-pointer-types',
'-D__TARGET_ARCH_' + arch_dict[cpu], '-mcpu=v3',
'-m@0@-endian'.format(host_machine.endian())] + sys_incls
if get_option('werror')
bpf_base_cflags += '-Werror'
endif
message('cpu=@0@ bpf_base_cflags=@1@'.format(cpu, bpf_base_cflags))
libbpf_c_headers = []