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
18cd $WORK
19
20# Disable UBSan vptr since Firestore depends on other libraries that are built
21# with -fno-rtti.
22export CFLAGS="$CFLAGS -fno-sanitize=vptr"
23export CXXFLAGS="$CXXFLAGS -fno-sanitize=vptr"
24
25# Build the project using cmake with FUZZING option enabled to link to OSS Fuzz
26# fuzzing library defined in ${LIB_FUZZING_ENGINE}.
27cd $SRC/firebase-ios-sdk
28mkdir build && cd build
29cmake -DFUZZING=ON ..
30make -j$(nproc)
31
32# Copy fuzzing targets, dictionaries, and zipped corpora to $OUT.
33FUZZERS_DIR=Firestore/fuzzing
34find ${FUZZERS_DIR} -name '*_fuzzer' -exec cp -v '{}' $OUT ';'
35find ${FUZZERS_DIR} -name '*_fuzzer.dict' -exec cp -v '{}' $OUT ';'
36find ${FUZZERS_DIR} -name "*_fuzzer_seed_corpus" -type d -execdir zip -r ${OUT}/{}.zip {} ';'
37