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# setup 19build=${WORK}/build 20 21# cleanup 22rm -rf ${build} 23mkdir -p ${build} 24 25# prepare cross file for i386 compiliation 26if [ "$ARCHITECTURE" = "i386" ]; then 27 MESON_CFLAGS="'$(echo $CFLAGS | sed -e 's/ /;, ;/g' | tr \; \')'" 28 MESON_CXXFLAGS="'$(echo $CXXFLAGS | sed -e 's/ /;, ;/g' | tr \; \')'" 29 sed -e "s/CC$/'$CC'/; s/CXX$/'$CXX'/; s/CFLAGS$/[$MESON_CFLAGS]/; s/CXXFLAGS$/[$MESON_CXXFLAGS]/" < ${SRC}/linux32.meson > ${WORK}/linux32.meson 30 CROSS="--cross-file ${WORK}/linux32.meson" 31fi 32 33# build library 34meson -Denable_tools=false -Dfuzzing_engine=oss-fuzz \ 35 -Db_lundef=false -Ddefault_library=static -Dbuildtype=debugoptimized \ 36 -Dlogging=false -Dfuzzer_ldflags=$LIB_FUZZING_ENGINE \ 37 ${CROSS:-} \ 38 ${build} 39ninja -j $(nproc) -C ${build} 40 41# prepare seed corpus 42rm -rf ${WORK}/tmp 43mkdir -p ${WORK}/tmp/testdata 44unzip -q $SRC/dav1d_fuzzer_seed_corpus.zip -d ${WORK}/tmp/testdata 45cp $SRC/dec_fuzzer_seed_corpus.zip ${WORK}/tmp/seed_corpus.zip 46(cd ${WORK}/tmp && zip -q -m -r -0 ${WORK}/tmp/seed_corpus.zip testdata) 47 48# copy fuzzers and link testdata 49for fuzzer in $(find ${build}/tests/libfuzzer -maxdepth 1 -type f -executable -name 'dav1d_fuzzer*'); do 50 cp "${fuzzer}" $OUT/ 51 cp ${WORK}/tmp/seed_corpus.zip $OUT/$(basename "$fuzzer")_seed_corpus.zip 52done 53