2020-04-02 15:04:22 +00:00
|
|
|
#!/bin/bash -eu
|
|
|
|
# Copyright 2020 Google Inc.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
|
2020-06-05 20:57:57 +00:00
|
|
|
# Unpack the file and cd into it
|
2022-01-26 16:47:59 +00:00
|
|
|
tar -zxf xpdf-latest.tar.gz
|
2020-06-05 20:57:57 +00:00
|
|
|
dir_name=`tar -tzf xpdf-latest.tar.gz | head -1 | cut -f1 -d"/"`
|
|
|
|
cd $dir_name
|
2020-04-02 15:04:22 +00:00
|
|
|
|
2022-02-05 21:54:41 +00:00
|
|
|
PREFIX=$WORK/prefix
|
|
|
|
mkdir -p $PREFIX
|
|
|
|
|
|
|
|
export PKG_CONFIG="`which pkg-config` --static"
|
|
|
|
export PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig
|
|
|
|
export PATH=$PREFIX/bin:$PATH
|
|
|
|
pushd $SRC/freetype
|
|
|
|
./autogen.sh
|
|
|
|
./configure --prefix="$PREFIX" --disable-shared PKG_CONFIG_PATH="$PKG_CONFIG_PATH" --with-png=no --with-zlib=no
|
|
|
|
make -j$(nproc)
|
|
|
|
make install
|
|
|
|
popd
|
|
|
|
|
2020-04-02 15:04:22 +00:00
|
|
|
# Make minor change in the CMakeFiles file.
|
|
|
|
sed -i 's/#--- object files needed by XpdfWidget/add_library(testXpdfStatic STATIC $<TARGET_OBJECTS:xpdf_objs>)\n#--- object files needed by XpdfWidget/' ./xpdf/CMakeLists.txt
|
2022-02-05 21:54:41 +00:00
|
|
|
sed -i 's/#--- pdftops/add_library(testXpdfWidgetStatic STATIC $<TARGET_OBJECTS:xpdf_widget_objs>\n $<TARGET_OBJECTS:splash_objs>\n $<TARGET_OBJECTS:xpdf_objs>\n ${FREETYPE_LIBRARY}\n ${FREETYPE_OTHER_LIBS})\n#--- pdftops/' ./xpdf/CMakeLists.txt
|
2020-04-02 15:04:22 +00:00
|
|
|
|
|
|
|
# Build the project
|
|
|
|
mkdir build && cd build
|
|
|
|
export LD=$CXX
|
2022-01-26 16:47:59 +00:00
|
|
|
cmake ../ -DCMAKE_C_FLAGS="$CFLAGS" -DCMAKE_CXX_FLAGS="$CXXFLAGS" \
|
2022-02-05 21:54:41 +00:00
|
|
|
-DOPI_SUPPORT=ON -DSPLASH_CMYK=ON -DMULTITHREADED=ON \
|
|
|
|
-DUSE_EXCEPTIONS=ON -DXPDFWIDGET_PRINTING=ON -DFREETYPE_DIR="$PREFIX"
|
|
|
|
make
|
2020-04-02 15:04:22 +00:00
|
|
|
|
|
|
|
# Build fuzzers
|
2022-04-07 01:45:37 +00:00
|
|
|
for fuzzer in zxdoc pdfload JBIG2; do
|
2020-06-13 15:13:26 +00:00
|
|
|
cp ../../fuzz_$fuzzer.cc .
|
|
|
|
$CXX fuzz_$fuzzer.cc -o $OUT/fuzz_$fuzzer $CXXFLAGS $LIB_FUZZING_ENGINE \
|
2022-02-05 21:54:41 +00:00
|
|
|
./xpdf/libtestXpdfStatic.a ./fofi/libfofi.a ./goo/libgoo.a ./splash/libsplash.a ./xpdf/libtestXpdfWidgetStatic.a /work/prefix/lib/libfreetype.a \
|
|
|
|
-I../ -I../goo -I../fofi -I. -I../xpdf -I../splash
|
2020-06-13 15:13:26 +00:00
|
|
|
done
|
2020-06-16 14:07:37 +00:00
|
|
|
|
|
|
|
# Copy over options files
|
2022-04-12 18:48:27 +00:00
|
|
|
cp $SRC/fuzz_*.options $OUT/
|