blob: ad3ffd79813b093404a3cc3c42c51fc2df44dcdf [file] [log] [blame]
Damien Neil9dd71482020-02-05 11:42:35 -08001# Copyright 2020 The Go Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style
3# license that can be found in the LICENSE file.
4
5# This script is executed by OSS-Fuzz's build to create fuzzer binaries.
6
7function compile_fuzzer {
8 path=$1
9 function=$2
10 fuzzer=$3
11
12 # Instrument all Go files relevant to this fuzzer
13 go-fuzz-build -tags=protolegacy -libfuzzer -func $function -o $fuzzer.a $path
14
15 # Instrumented, compiled Go ($fuzzer.a) + fuzzing engine = fuzzer binary
16 $CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.a -lpthread -o $OUT/$fuzzer
17}
18
19for x in internal/fuzz/*; do
20 if [ -d $x/corpus ]; then
21 name=$(basename $x)
22 compile_fuzzer ./$x Fuzz $name
23 zip -jr $OUT/${name}_seed_corpus.zip $x/corpus
24 fi
25done