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
18export PATH=${PATH}:${PWD}/../boost
19export BOOST_ROOT=${PWD}/../boost
20export BOOST_BUILD_PATH=${PWD}/../boost/tools/build
21# when building b2, we don't want sanitizers enabled
22ASAN_OPTIONS=detect_leaks=0
23(cd ${PWD}/../boost && ./bootstrap.sh && ./b2 headers)
24
25echo "CXX=$CXX"
26echo "CXXFLAGS=$CXXFLAGS"
27
28echo "using clang : ossfuzz : $CXX : <compileflags>\"$CXXFLAGS\" <linkflags>\"$CXXFLAGS\" <linkflags>\"${LIB_FUZZING_ENGINE}\" ;" >project-config.jam
29cat project-config.jam
30cd fuzzers
31# we don't want sanitizers enabled on b2 itself
32ASAN_OPTIONS=detect_leaks=0 b2 clang-ossfuzz -j$(nproc) crypto=openssl fuzz=external sanitize=off stage-large logging=off
33cp fuzzers/* $OUT
34
35wget --no-verbose https://github.com/arvidn/libtorrent/releases/download/2.0/corpus.zip
36unzip -q corpus.zip
37cd corpus
38for f in *; do
39zip -q -r ${OUT}/fuzzer_${f}_seed_corpus.zip ${f}
40done
41