1*a97c2a1fSXin Li#!/bin/bash -eu 2*a97c2a1fSXin Li# 3*a97c2a1fSXin Li# Licensed under the Apache License, Version 2.0 (the "License"); 4*a97c2a1fSXin Li# you may not use this file except in compliance with the License. 5*a97c2a1fSXin Li# You may obtain a copy of the License at 6*a97c2a1fSXin Li# 7*a97c2a1fSXin Li# http://www.apache.org/licenses/LICENSE-2.0 8*a97c2a1fSXin Li# 9*a97c2a1fSXin Li# Unless required by applicable law or agreed to in writing, software 10*a97c2a1fSXin Li# distributed under the License is distributed on an "AS IS" BASIS, 11*a97c2a1fSXin Li# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*a97c2a1fSXin Li# See the License for the specific language governing permissions and 13*a97c2a1fSXin Li# limitations under the License. 14*a97c2a1fSXin Li# 15*a97c2a1fSXin Li################################################################################ 16*a97c2a1fSXin Li# Ensure SRC and WORK are set 17*a97c2a1fSXin Litest "${SRC}" != "" || exit 1 18*a97c2a1fSXin Litest "${WORK}" != "" || exit 1 19*a97c2a1fSXin Litest "${OUT}" != "" || exit 1 20*a97c2a1fSXin Li 21*a97c2a1fSXin Li#Opt out of shift sanitizers in undefined sanitizer 22*a97c2a1fSXin Liif [[ $SANITIZER = *undefined* ]]; then 23*a97c2a1fSXin Li CFLAGS="$CFLAGS -fno-sanitize=shift" 24*a97c2a1fSXin Li CXXFLAGS="$CXXFLAGS -fno-sanitize=shift" 25*a97c2a1fSXin Lifi 26*a97c2a1fSXin Li 27*a97c2a1fSXin Li# Build libmpeg2 28*a97c2a1fSXin Libuild_dir=$WORK/build 29*a97c2a1fSXin Lirm -rf ${build_dir} 30*a97c2a1fSXin Limkdir -p ${build_dir} 31*a97c2a1fSXin Lipushd ${build_dir} 32*a97c2a1fSXin Li 33*a97c2a1fSXin Licmake $SRC/libmpeg2 34*a97c2a1fSXin Limake -j$(nproc) mpeg2_dec_fuzzer 35*a97c2a1fSXin Licp ${build_dir}/mpeg2_dec_fuzzer $OUT/ 36*a97c2a1fSXin Lipopd 37*a97c2a1fSXin Li 38*a97c2a1fSXin Licp $SRC/mpeg2_dec_fuzzer_seed_corpus.zip $OUT/mpeg2_dec_fuzzer_seed_corpus.zip 39*a97c2a1fSXin Licp $SRC/libmpeg2/fuzzer/mpeg2_dec_fuzzer.dict $OUT/mpeg2_dec_fuzzer.dict 40