meson: wire up fuzzers

Meson does not yet know to build our fuzzers. Introduce a new build
option "fuzzers" and wire up the fuzzers in case it is enabled. Adapt
our CI jobs so that they build the fuzzers by default.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Patrick Steinhardt 2025-01-22 13:05:50 +01:00 committed by Junio C Hamano
parent 88d4bff8c3
commit 28911f7dca
4 changed files with 28 additions and 1 deletions

View File

@ -53,7 +53,8 @@ case "$jobname" in
*-meson) *-meson)
group "Configure" meson setup build . \ group "Configure" meson setup build . \
--warnlevel 2 --werror \ --warnlevel 2 --werror \
--wrap-mode nofallback --wrap-mode nofallback \
-Dfuzzers=true
group "Build" meson compile -C build -- group "Build" meson compile -C build --
if test -n "$run_tests" if test -n "$run_tests"
then then

View File

@ -1906,6 +1906,10 @@ if get_option('tests')
subdir('t') subdir('t')
endif endif


if get_option('fuzzers')
subdir('oss-fuzz')
endif

subdir('bin-wrappers') subdir('bin-wrappers')
if get_option('docs') != [] if get_option('docs') != []
subdir('Documentation') subdir('Documentation')

View File

@ -95,3 +95,5 @@ option('tests', type: 'boolean', value: true,
description: 'Enable building tests. This requires Perl, but is separate from the "perl" option such that you can build tests without Perl features enabled.') description: 'Enable building tests. This requires Perl, but is separate from the "perl" option such that you can build tests without Perl features enabled.')
option('test_output_directory', type: 'string', option('test_output_directory', type: 'string',
description: 'Path to the directory used to store test outputs') description: 'Path to the directory used to store test outputs')
option('fuzzers', type: 'boolean', value: false,
description: 'Enable building fuzzers.')

20
oss-fuzz/meson.build Normal file
View File

@ -0,0 +1,20 @@
fuzz_programs = [
'fuzz-commit-graph.c',
'fuzz-config.c',
'fuzz-credential-from-url-gently.c',
'fuzz-date.c',
'fuzz-pack-headers.c',
'fuzz-pack-idx.c',
'fuzz-parse-attr-line.c',
'fuzz-url-decode-mem.c',
]

foreach fuzz_program : fuzz_programs
executable(fs.stem(fuzz_program),
sources: [
'dummy-cmd-main.c',
fuzz_program,
],
dependencies: [libgit, common_main],
)
endforeach