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>
Patrick Steinhardt committed
Jan 22, 2025 at 13:05 UTC
28911f7dcad1ccc6ac4f6939036de76bb4f4c09b
4 files changed
+28
-1
ci/run-build-and-tests.sh
+2
-1
@@ -53,7 +53,8 @@ case "$jobname" in
53
*-meson)
54
group "Configure" meson setup build . \
55
--warnlevel 2 --werror \
56
- --wrap-mode nofallback
56
+ --wrap-mode nofallback \
57
+ -Dfuzzers=true
58
group "Build" meson compile -C build --
59
if test -n "$run_tests"
60
then
meson.build
+4
@@ -1906,6 +1906,10 @@ if get_option('tests')
1906
subdir('t')
1907
endif
1908
1909
+if get_option('fuzzers')
1910
+ subdir('oss-fuzz')
1911
+endif
1912
+
1913
subdir('bin-wrappers')
1914
if get_option('docs') != []
1915
subdir('Documentation')
meson_options.txt
+2
@@ -95,3 +95,5 @@ option('tests', type: 'boolean', value: true,
95
description: 'Enable building tests. This requires Perl, but is separate from the "perl" option such that you can build tests without Perl features enabled.')
96
option('test_output_directory', type: 'string',
97
description: 'Path to the directory used to store test outputs')
98
+option('fuzzers', type: 'boolean', value: false,
99
+ description: 'Enable building fuzzers.')
oss-fuzz/meson.build
new
+20
@@ -0,0 +1,20 @@
1
+fuzz_programs = [
2
+ 'fuzz-commit-graph.c',
3
+ 'fuzz-config.c',
4
+ 'fuzz-credential-from-url-gently.c',
5
+ 'fuzz-date.c',
6
+ 'fuzz-pack-headers.c',
7
+ 'fuzz-pack-idx.c',
8
+ 'fuzz-parse-attr-line.c',
9
+ 'fuzz-url-decode-mem.c',
10
+]
11
+
12
+foreach fuzz_program : fuzz_programs
13
+ executable(fs.stem(fuzz_program),
14
+ sources: [
15
+ 'dummy-cmd-main.c',
16
+ fuzz_program,
17
+ ],
18
+ dependencies: [libgit, common_main],
19
+ )
20
+endforeach