1#!/bin/bash -eu 2# Copyright 2016 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 DEPS_PATH=$SRC/deps 19export PKG_CONFIG_PATH=$DEPS_PATH/lib/pkgconfig 20export CPPFLAGS="-I$DEPS_PATH/include" 21export LDFLAGS="-L$DEPS_PATH/lib" 22export CONFIG_SITE=$SRC/config.site 23export GNULIB_SRCDIR=$SRC/gnulib 24export GNULIB_TOOL=$GNULIB_SRCDIR/gnulib-tool 25 26 27cd $SRC/icu/source 28UBSAN_OPTIONS=detect_leaks=0 \ 29CFLAGS="$CFLAGS -fno-sanitize=vptr" \ 30CXXFLAGS="$CXXFLAGS -fno-sanitize=vptr" \ 31CPPFLAGS="$CPPFLAGS -fno-sanitize=vptr" \ 32./configure --disable-shared --enable-static --disable-extras --disable-icuio --disable-layoutex \ 33 --disable-tests --disable-samples --with-data-packaging=static --prefix=$DEPS_PATH 34# ugly hack to avoid build error 35echo '#include <locale.h>' >>i18n/digitlst.h 36 37# Hack so that upgrade to Ubuntu 20.04 works. 38ln -s /usr/include/locale.h /usr/include/xlocale.h 39 40make -j 41make install 42 43cd $SRC/libunistring 44./autogen.sh 45ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=detect_leaks=0 \ 46 ./configure --enable-static --disable-shared --prefix=$DEPS_PATH 47make -j 48make install 49 50cd $SRC/libidn 51./bootstrap 52ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=detect_leaks=0 \ 53 ./configure --enable-static --disable-shared --disable-doc --prefix=$DEPS_PATH 54make -j 55make install 56 57cd $SRC/libidn2 58./bootstrap 59ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=detect_leaks=0 \ 60 ./configure --enable-static --disable-shared --disable-doc --disable-gcc-warnings --prefix=$DEPS_PATH 61make -j 62make install 63 64 65cd $SRC/libpsl 66./autogen.sh 67export CXXFLAGS="$CXXFLAGS -L$DEPS_PATH/lib/" 68if test $SANITIZER = "undefined"; then 69 # libicu doesn't work with -fsanitizer=undefined, see projects/icu/project.yaml 70 builds="libidn2 libidn none" 71else 72 builds="libicu libidn2 libidn none" 73fi 74for build in $builds; do 75 unset LIBS 76 if test $build = "none"; then 77 BUILD_FLAGS="--disable-runtime --disable-builtin" 78 # convert PSL to NFC 79 cp -p list/public_suffix_list.dat list/public_suffix_list.dat.org 80 LC_ALL=C.UTF-8 python3 -c $'import unicodedata\nimport sys\nfor line in sys.stdin:\n sys.stdout.write(unicodedata.normalize("NFC", line))' <list/public_suffix_list.dat.org >list/public_suffix_list.dat 81 else 82 BUILD_FLAGS="--enable-runtime=$build --enable-builtin=$build" 83 if test $build = "libicu"; then 84 export LIBS="-lstdc++" 85 fi 86 fi 87 # older m4 iconv detection has memleaks, so switch leak detection off 88 ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=detect_leaks=0 \ 89 ./configure --enable-static --disable-shared --disable-gtk-doc $BUILD_FLAGS --prefix=$DEPS_PATH 90 make clean 91 make -j 92 make -j check 93 make -C fuzz oss-fuzz 94 find fuzz -name '*_fuzzer' -exec cp -v '{}' $OUT ';' 95done 96 97cd fuzz 98find . -name '*_fuzzer.dict' -exec cp -v '{}' $OUT ';' 99find . -name '*_fuzzer.options' -exec cp -v '{}' $OUT ';' 100 101for dir in *_fuzzer.in; do 102 fuzzer=$(basename $dir .in) 103 zip -rj "$OUT/${fuzzer}_seed_corpus.zip" "${dir}/" 104done 105