1#!/bin/bash -eux 2# 3# Copyright 2016 Google Inc. 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16# 17################################################################################ 18 19mkdir $WORK/icu 20cd $WORK/icu 21 22# TODO: icu build failes without -DU_USE_STRTOD_L=0 23DEFINES="-DU_CHARSET_IS_UTF8=1 -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 -DU_USE_STRTOD_L=0" 24CFLAGS="$CFLAGS $DEFINES" 25CXXFLAGS="$CXXFLAGS $DEFINES" 26 27CFLAGS=$CFLAGS CXXFLAGS=$CXXFLAGS CC=$CC CXX=$CXX \ 28 /bin/bash $SRC/icu/icu4c/source/runConfigureICU Linux \ 29 --with-library-bits=64 --with-data-packaging=static --enable-static --disable-shared 30 31export ASAN_OPTIONS="detect_leaks=0" 32export UBSAN_OPTIONS="detect_leaks=0" 33 34make -j$(nproc) 35 36$CXX $CXXFLAGS -std=c++11 -c $SRC/icu/icu4c/source/test/fuzzer/locale_util.cpp \ 37 -I$SRC/icu4c/source/test/fuzzer 38 39FUZZER_PATH=$SRC/icu/icu4c/source/test/fuzzer 40# Assumes that all fuzzers files end with'_fuzzer.cpp'. 41FUZZERS=$FUZZER_PATH/*_fuzzer.cpp 42 43for fuzzer in $FUZZERS; do 44 file=${fuzzer:${#FUZZER_PATH}+1} 45 $CXX $CXXFLAGS -std=c++11 \ 46 $fuzzer -o $OUT/${file/.cpp/} locale_util.o \ 47 -I$SRC/icu/icu4c/source/common -I$SRC/icu/icu4c/source/i18n -L$WORK/icu/lib \ 48 $LIB_FUZZING_ENGINE -licui18n -licuuc -licutu -licudata 49done 50 51# Assumes that all seed files end with '*_fuzzer_seed_corpus.txt'. 52CORPUS=$SRC/icu/icu4c/source/test/fuzzer/*_fuzzer_seed_corpus.txt 53for corpus in $CORPUS; do 54 zipfile=${corpus:${#FUZZER_PATH}+1} 55 zip $OUT/${zipfile/.txt/.zip} $corpus 56done 57 58cp $SRC/icu/icu4c/source/test/fuzzer/*.dict $OUT/ 59