summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-12-02 13:49:24 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-12-02 13:51:31 +0100
commit7e299ffe108fc0265553d30cf63febc6e6609087 (patch)
tree2b92b900d263c5b5ba446f1f1c149abb2855f9db
parentce9067697bfc8075c10d2d618e84dd22d4ef4351 (diff)
downloadsystemd-meson-allows-fuzzer-building.tar.gz
meson: allow fuzzers to be built even if fuzz testing is disabledmeson-allows-fuzzer-building
This makes commands like 'ninja -C build fuzz-journal-remote' or 'ninja -C build fuzzers' work, even if we have -Dfuzz-tests=false. Two advantages: correctness of the meson declarations is verified even if fuzzers are not built, and it easier to do a one-off build to check for regressions or such. Follow-up for 1763ef1d49cc1263b40f157060a61cdd6e91d3a4.
-rw-r--r--meson.build57
1 files changed, 28 insertions, 29 deletions
diff --git a/meson.build b/meson.build
index 73cff4a6f7..bf291027ea 100644
--- a/meson.build
+++ b/meson.build
@@ -3438,40 +3438,39 @@ endif
fuzzer_exes = []
-if fuzz_tests or fuzzer_build
- foreach tuple : fuzzers
- sources = tuple[0]
- link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
- dependencies = tuple[2]
- defs = tuple.length() >= 4 ? tuple[3] : []
- incs = tuple.length() >= 5 ? tuple[4] : includes
- link_args = []
-
- if want_ossfuzz
+foreach tuple : fuzzers
+ sources = tuple[0]
+ link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
+ dependencies = tuple[2]
+ defs = tuple.length() >= 4 ? tuple[3] : []
+ incs = tuple.length() >= 5 ? tuple[4] : includes
+ link_args = []
+
+ if want_ossfuzz
+ dependencies += fuzzing_engine
+ elif want_libfuzzer
+ if fuzzing_engine.found()
dependencies += fuzzing_engine
- elif want_libfuzzer
- if fuzzing_engine.found()
- dependencies += fuzzing_engine
- else
- link_args += ['-fsanitize=fuzzer']
- endif
else
- sources += 'src/fuzz/fuzz-main.c'
+ link_args += ['-fsanitize=fuzzer']
endif
+ else
+ sources += 'src/fuzz/fuzz-main.c'
+ endif
- name = sources[0].split('/')[-1].split('.')[0]
+ name = sources[0].split('/')[-1].split('.')[0]
- fuzzer_exes += executable(
- name,
- sources,
- include_directories : [incs, include_directories('src/fuzz')],
- link_with : link_with,
- dependencies : dependencies,
- c_args : defs,
- link_args: link_args,
- install : false)
- endforeach
-endif
+ fuzzer_exes += executable(
+ name,
+ sources,
+ include_directories : [incs, include_directories('src/fuzz')],
+ link_with : link_with,
+ dependencies : dependencies,
+ c_args : defs,
+ link_args: link_args,
+ install : false,
+ build_by_default : fuzz_tests or fuzzer_build)
+endforeach
run_target(
'fuzzers',