• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash -eu
2# Copyright 2019 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
18cd $SRC
19tar xzf gperf*.tar.gz && rm -f gperf*.tar.gz
20cd gperf*
21FUZZ_CFLAGS="${CFLAGS}"
22FUZZ_CXXFLAGS="${CXXFLAGS}"
23unset CFLAGS
24unset CXXFLAGS
25# gperf is a code generator, so no need to sanitize it
26./configure --prefix=/usr
27make -j$(nproc) install
28export CFLAGS="${FUZZ_CFLAGS}"
29export CXXFLAGS="${FUZZ_CXXFLAGS}"
30
31
32cd $SRC
33cd extra-cmake-modules
34cmake .
35make install
36
37cd $SRC
38cd qtbase
39# add the flags to Qt build too
40sed -i -e "s/QMAKE_CXXFLAGS    += -stdlib=libc++/QMAKE_CXXFLAGS    += -stdlib=libc++  $CXXFLAGS\nQMAKE_CFLAGS += $CFLAGS/g" mkspecs/linux-clang-libc++/qmake.conf
41sed -i -e "s/QMAKE_LFLAGS      += -stdlib=libc++/QMAKE_LFLAGS      += -stdlib=libc++ -lpthread $CXXFLAGS/g" mkspecs/linux-clang-libc++/qmake.conf
42# make qmake compile faster
43sed -i -e "s/MAKE\")/MAKE\" -j$(nproc))/g" configure
44./configure --glib=no --libpng=qt -opensource -confirm-license -static -no-opengl -no-icu -platform linux-clang-libc++ -v
45cd src
46../bin/qmake -o Makefile src.pro
47make sub-corelib sub-rcc -j$(nproc)
48
49cd $SRC
50cd kcodecs
51cmake . -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=$SRC/qtbase
52make -j$(nproc) VERBOSE=1
53
54
55$CXX $CXXFLAGS -fPIC -std=c++11 $SRC/kcodecs_fuzzer.cc -o $OUT/kcodecs_fuzzer \
56               -I $SRC/qtbase/include/QtCore/ -I $SRC/qtbase/include/ -I $SRC/kcodecs/src \
57               -I $SRC/kcodecs/src/probers -L $SRC/qtbase/lib -L $SRC/kcodecs/lib \
58               -lQt5Core -lm -lqtpcre2 -ldl -lpthread $LIB_FUZZING_ENGINE -lKF5Codecs
59
60zip -qr $OUT/kcodecs_fuzzer_seed_corpus.zip $SRC/uchardet/test/ $SRC/kcodecs/autotests/data
61