• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
18pushd $SRC/freetype2
19./autogen.sh
20./configure --prefix="$WORK" --disable-shared PKG_CONFIG_PATH="$WORK/lib/pkgconfig"
21make -j$(nproc)
22make install
23
24mkdir -p $WORK/poppler
25pushd $WORK/poppler
26cmake $SRC/poppler \
27  -DCMAKE_BUILD_TYPE=debug \
28  -DBUILD_SHARED_LIBS=OFF \
29  -DFONT_CONFIGURATION=generic \
30  -DENABLE_DCTDECODER=none \
31  -DENABLE_LIBOPENJPEG=none \
32  -DENABLE_CMS=none \
33  -DENABLE_LIBPNG=OFF \
34  -DENABLE_ZLIB=OFF \
35  -DENABLE_LIBTIFF=OFF \
36  -DENABLE_LIBJPEG=OFF \
37  -DENABLE_GLIB=OFF \
38  -DENABLE_LIBCURL=OFF \
39  -DENABLE_QT5=OFF \
40  -DENABLE_UTILS=OFF \
41  -DWITH_Cairo=OFF \
42  -DWITH_NSS3=OFF \
43  -DFREETYPE_INCLUDE_DIRS=$WORK/include/freetype2 \
44  -DFREETYPE_LIBRARY=$WORK/lib
45make -j$(nproc) poppler poppler-cpp
46
47fuzz_target=pdf_fuzzer
48
49$CXX $CXXFLAGS -std=c++11 -I$SRC/poppler/cpp \
50    $SRC/fuzz/pdf_fuzzer.cc -o $OUT/$fuzz_target \
51    $LIB_FUZZING_ENGINE $WORK/poppler/cpp/libpoppler-cpp.a $WORK/poppler/libpoppler.a $WORK/lib/libfreetype.a
52
53mv $SRC/{*.zip,*.dict} $OUT
54
55if [ ! -f "${OUT}/${fuzz_target}_seed_corpus.zip" ]; then
56  echo "missing seed corpus"
57  exit 1
58fi
59
60if [ ! -f "${OUT}/${fuzz_target}.dict" ]; then
61  echo "missing dictionary"
62  exit 1
63fi
64