diff mbox series

[6/9] meson: wire up fuzzers

Message ID 20250113-b4-pks-meson-additions-v1-6-97f6a93f691d@pks.im (mailing list archive)
State Superseded
Headers show
Series meson: a couple of additions | expand

Commit Message

Patrick Steinhardt Jan. 13, 2025, 8:33 a.m. UTC
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>
---
 ci/run-build-and-tests.sh |  3 ++-
 meson.build               |  4 ++++
 meson_options.txt         |  2 ++
 oss-fuzz/meson.build      | 20 ++++++++++++++++++++
 4 files changed, 28 insertions(+), 1 deletion(-)

Comments

Junio C Hamano Jan. 13, 2025, 5:48 p.m. UTC | #1
Patrick Steinhardt <ps@pks.im> writes:

> 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.

Nice.  We have shipped a feature release with bunch of meson.build
files, but it has known holes we need to fill, and this is one of
the missing things.  Let's make it a goal to achieve feature parity
within two releases---if we can do so in one release cycle, that
would be great ;-)

Thanks.
Patrick Steinhardt Jan. 14, 2025, 10:31 a.m. UTC | #2
On Mon, Jan 13, 2025 at 09:48:07AM -0800, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > 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.
> 
> Nice.  We have shipped a feature release with bunch of meson.build
> files, but it has known holes we need to fill, and this is one of
> the missing things.  Let's make it a goal to achieve feature parity
> within two releases---if we can do so in one release cycle, that
> would be great ;-)

Yeah, I already had a couple of features planned for this release cycle
anyway, most importantly static analysis. I'll have to take a look at
which other features are still missing -- hints are welcome.

One of the known omissions is most of "contrib/" and "gitk/". I'm not
sure whether these should be included or not. For the former I'm leaning
into the direction of not doing it, but can do so if others disagree
with me. For the latter I'd leave it up to Johannes to decide (cc'd).

Patrick
diff mbox series

Patch

diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh
index 76667a1277720d74e09e8da227b5e0832003e0e2..6c828c3b755153dab179f73346e7124bda49c90e 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 771bdded484a0c0e8638e7c6555e3f4e09e64025..5e1373f6a52a91beb527d00d8fd5c55d377c718b 100644
--- a/meson.build
+++ b/meson.build
@@ -1899,6 +1899,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 89b01bad042b533b23e0e2b4b780ce152ee688c8..34ba679cf931b67a794a9bb7e765bfb22106381e 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 0000000000000000000000000000000000000000..ed79665501655eae4948623c07114fab23a55393
--- /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