forked from gentoo-utils/gentoo-utils
setup meson to allow building multiple fuzzers easily
This commit is contained in:
@@ -1,40 +1,59 @@
|
||||
cbindgen = find_program('cbindgen')
|
||||
|
||||
gencorpus = executable(
|
||||
'gencorpus',
|
||||
'gencorpus.rs',
|
||||
dependencies: [mon],
|
||||
link_with: [gentoo_utils],
|
||||
)
|
||||
fuzzers = {}
|
||||
|
||||
corpus_directory = meson.current_build_dir() / 'corpus'
|
||||
subdir('atom')
|
||||
|
||||
corpus = custom_target(
|
||||
'corpus',
|
||||
output: 'corpus',
|
||||
command: [gencorpus, corpus_directory],
|
||||
)
|
||||
foreach fuzzer, sources : fuzzers
|
||||
gencorpus_rs = sources[0]
|
||||
fuzz_rs = sources[1]
|
||||
|
||||
fuzz_h = custom_target(
|
||||
'fuzz_h',
|
||||
input: 'fuzz.rs',
|
||||
output: 'fuzz.h',
|
||||
command: [cbindgen, '@INPUT@', '-o', '@OUTPUT'],
|
||||
)
|
||||
gencorpus = executable(
|
||||
fuzzer + '_' + 'gencorpus',
|
||||
gencorpus_rs,
|
||||
dependencies: [mon],
|
||||
link_with: [gentoo_utils],
|
||||
)
|
||||
|
||||
fuzz_rs = static_library(
|
||||
'fuzz_rs',
|
||||
'fuzz.rs',
|
||||
rust_abi: 'c',
|
||||
rust_args: [
|
||||
'-Cpasses=sancov-module',
|
||||
'-Cllvm-args=-sanitizer-coverage-level=3',
|
||||
'-Cllvm-args=-sanitizer-coverage-inline-8bit-counters',
|
||||
],
|
||||
dependencies: [mon],
|
||||
link_with: [gentoo_utils],
|
||||
)
|
||||
corpus_directory = fuzzer + '_' + 'corpus'
|
||||
|
||||
fuzz = executable('fuzz', link_args: ['-fsanitize=fuzzer'], link_with: [fuzz_rs])
|
||||
corpus = custom_target(
|
||||
fuzzer + '_' + 'corpus',
|
||||
output: fuzzer + '_' + 'corpus',
|
||||
command: [gencorpus, corpus_directory],
|
||||
)
|
||||
|
||||
test('fuzz', fuzz, args: [corpus_directory], depends: [corpus], timeout: 0)
|
||||
fuzz_h = custom_target(
|
||||
fuzzer + '_' + 'fuzz_h',
|
||||
input: fuzz_rs,
|
||||
output: fuzzer + '_' + 'fuzz.h',
|
||||
command: [cbindgen, '@INPUT@', '-o', '@OUTPUT'],
|
||||
)
|
||||
|
||||
fuzz_rs = static_library(
|
||||
fuzzer + '.rs',
|
||||
fuzz_rs,
|
||||
rust_abi: 'c',
|
||||
rust_args: [
|
||||
'-Cpasses=sancov-module',
|
||||
'-Cllvm-args=-sanitizer-coverage-level=3',
|
||||
'-Cllvm-args=-sanitizer-coverage-inline-8bit-counters',
|
||||
],
|
||||
dependencies: [mon],
|
||||
link_with: [gentoo_utils],
|
||||
)
|
||||
|
||||
fuzz = executable(
|
||||
fuzzer + '_' + 'fuzzer',
|
||||
link_args: ['-fsanitize=fuzzer'],
|
||||
link_with: [fuzz_rs],
|
||||
)
|
||||
|
||||
test(
|
||||
fuzzer + '_' + 'fuzz',
|
||||
fuzz,
|
||||
args: [corpus_directory],
|
||||
depends: [corpus],
|
||||
timeout: 0,
|
||||
)
|
||||
endforeach
|
||||
|
||||
Reference in New Issue
Block a user