summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-01-22 13:05:50 +0100
committerJunio C Hamano <gitster@pobox.com>2025-01-22 12:37:33 -0800
commit28911f7dcad1ccc6ac4f6939036de76bb4f4c09b (patch)
treedb6ebb21a3b8307e0a827bbf77266839c99b3dbb
parent88d4bff8c376cae3029b7da94a21c4fd4ac0249e (diff)
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>
-rwxr-xr-xci/run-build-and-tests.sh3
-rw-r--r--meson.build4
-rw-r--r--meson_options.txt2
-rw-r--r--oss-fuzz/meson.build20
4 files changed, 28 insertions, 1 deletions
diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh
index 76667a1277..6c828c3b75 100755
--- a/ci/run-build-and-tests.sh
+++ b/ci/run-build-and-tests.sh
@@ -53,7 +53,8 @@ case "$jobname" in
*-meson)
group "Configure" meson setup build . \
--warnlevel 2 --werror \
- --wrap-mode nofallback
+ --wrap-mode nofallback \
+ -Dfuzzers=true
group "Build" meson compile -C build --
if test -n "$run_tests"
then
diff --git a/meson.build b/meson.build
index a59072edf5..052bd80ac4 100644
--- a/meson.build
+++ b/meson.build
@@ -1906,6 +1906,10 @@ if get_option('tests')
subdir('t')
endif
+if get_option('fuzzers')
+ subdir('oss-fuzz')
+endif
+
subdir('bin-wrappers')
if get_option('docs') != []
subdir('Documentation')
diff --git a/meson_options.txt b/meson_options.txt
index 89b01bad04..34ba679cf9 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -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.')
option('test_output_directory', type: 'string',
description: 'Path to the directory used to store test outputs')
+option('fuzzers', type: 'boolean', value: false,
+ description: 'Enable building fuzzers.')
diff --git a/oss-fuzz/meson.build b/oss-fuzz/meson.build
new file mode 100644
index 0000000000..ed79665501
--- /dev/null
+++ b/oss-fuzz/meson.build
@@ -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