1#!/bin/bash -eu 2# Copyright 2018 Google Inc. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15# 16################################################################################ 17 18# build project 19mkdir -p build 20cd build 21cmake .. -DCMAKE_INSTALL_PREFIX="$WORK" \ 22 -DBUILD_SHARED_LIBS=OFF \ 23 -DBUILD_CLAR=OFF \ 24 -DUSE_HTTPS=OFF \ 25 -DUSE_SSH=OFF \ 26 -DUSE_BUNDLED_ZLIB=ON \ 27 28make -j$(nproc) 29make install 30 31for fuzzer in ../fuzzers/*_fuzzer.c 32do 33 fuzzer_name=$(basename "${fuzzer%.c}") 34 35 $CC $CFLAGS -c -I"$WORK/include" -I"$SRC/libgit2/src" \ 36 -DLIBGIT2_NO_FEATURES_H \ 37 "$fuzzer" -o "$WORK/$fuzzer_name.o" 38 $CXX $CXXFLAGS -std=c++11 -o "$OUT/$fuzzer_name" \ 39 $LIB_FUZZING_ENGINE "$WORK/$fuzzer_name.o" "$WORK/lib/libgit2.a" 40 41 zip -j "$OUT/${fuzzer_name}_seed_corpus.zip" \ 42 ../fuzzers/corpora/${fuzzer_name%_fuzzer}/* 43done 44