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
18build_dir=$WORK/build-$SANITIZER
19install_dir=$WORK/install-$SANITIZER
20
21mkdir -p $build_dir
22pushd $build_dir
23cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=$install_dir \
24  -DBUILD_SHARED_LIBS=OFF -DOPENCV_GENERATE_PKGCONFIG=ON \
25  -DOPENCV_GENERATE_PKGCONFIG=ON -DOPENCV_FORCE_3RDPARTY_BUILD=ON \
26  -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_opencv_apps=OFF \
27  $SRC/opencv
28make -j$(nproc)
29make install
30popd
31
32pushd $SRC
33for fuzzer in core_fuzzer filestorage_read_file_fuzzer \
34   filestorage_read_filename_fuzzer filestorage_read_string_fuzzer \
35   generateusergallerycollage_fuzzer imdecode_fuzzer imencode_fuzzer \
36   imread_fuzzer; do
37$CXX $CXXFLAGS $LIB_FUZZING_ENGINE $fuzzer.cc -std=c++11 \
38-I$install_dir/include/opencv4 -L$install_dir/lib \
39-L$install_dir/lib/opencv4/3rdparty \
40-lopencv_dnn -lopencv_objdetect -lopencv_photo -lopencv_ml -lopencv_gapi \
41-lopencv_stitching -lopencv_video -lopencv_calib3d -lopencv_features2d \
42-lopencv_highgui -lopencv_videoio -lopencv_imgcodecs -lopencv_imgproc \
43-lopencv_flann -lopencv_core -llibjpeg-turbo -llibwebp -llibpng -llibtiff \
44-llibopenjp2 -lIlmImf -llibprotobuf -lquirc -lzlib -littnotify -lippiw \
45-lippicv -lade -ldl -lm -lpthread -lrt \
46-o $OUT/$fuzzer
47done
48popd
49