1#!/bin/bash -eu 2# Copyright 2020 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# Unpack the file and cd into it 19tar -zxvf xpdf-latest.tar.gz 20dir_name=`tar -tzf xpdf-latest.tar.gz | head -1 | cut -f1 -d"/"` 21cd $dir_name 22 23# Make minor change in the CMakeFiles file. 24sed -i 's/#--- object files needed by XpdfWidget/add_library(testXpdfStatic STATIC $<TARGET_OBJECTS:xpdf_objs>)\n#--- object files needed by XpdfWidget/' ./xpdf/CMakeLists.txt 25 26# Build the project 27mkdir build && cd build 28export LD=$CXX 29cmake ../ -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS" 30make -i || true 31 32# Build fuzzers 33for fuzzer in zxdoc pdfload; do 34 cp ../../fuzz_$fuzzer.cc . 35 $CXX fuzz_$fuzzer.cc -o $OUT/fuzz_$fuzzer $CXXFLAGS $LIB_FUZZING_ENGINE \ 36 ./xpdf/libtestXpdfStatic.a ./fofi/libfofi.a ./goo/libgoo.a \ 37 -I../ -I../goo -I../fofi -I. -I../xpdf 38done 39 40# Copy over options files 41cp $SRC/fuzz_pdfload.options $OUT/ 42