Add Google's brotli library.
diff --git a/.gitmodules b/.gitmodules
index 5580f7d..9b3e2b4 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -16,3 +16,6 @@
[submodule "external/boost"]
path = external/boost
url = https://github.com/boostorg/boost.git
+[submodule "external/brotli"]
+ path = external/brotli
+ url = https://github.com/google/brotli.git
diff --git a/external/brotli b/external/brotli
new file mode 160000
index 0000000..5c3a9a9
--- /dev/null
+++ b/external/brotli
@@ -0,0 +1 @@
+Subproject commit 5c3a9a937bd5978af08e06199a5e7e56cd6b2061
diff --git a/fuzzing/CMakeLists.txt b/fuzzing/CMakeLists.txt
index 10b2f1c..0e74d1d 100644
--- a/fuzzing/CMakeLists.txt
+++ b/fuzzing/CMakeLists.txt
@@ -66,6 +66,12 @@
set(BZIP2_BASE_DIR "${SUBMODULES_DIR}/bzip2")
set(BZIP2_STATIC_LIBRARY "${BZIP2_BASE_DIR}/libbz2.a")
+set(BROTLI_BASE_DIR "${SUBMODULES_DIR}/brotli")
+set(BROTLI_BUILD_DIR "${BROTLI_BASE_DIR}/build")
+set(BROTLI_STATIC_LIBRARY
+ "${BROTLI_BUILD_DIR}/libbrotlidec-static.a"
+ "${BROTLI_BUILD_DIR}/libbrotlicommon-static.a")
+
# ----------------------------------------------------------------------------
# functions:
diff --git a/fuzzing/scripts/build-fuzzers.sh b/fuzzing/scripts/build-fuzzers.sh
index 40e001a..7d33d61 100644
--- a/fuzzing/scripts/build-fuzzers.sh
+++ b/fuzzing/scripts/build-fuzzers.sh
@@ -21,10 +21,11 @@
# which would cause CMake's setup process to fail. See
# `fuzzing/src/fuzzing/CMakeLists.txt' for details.
-bash build/libarchive.sh
-bash build/bzip2.sh
-bash build/freetype.sh
-bash build/boost.sh
-bash build/targets.sh
+bash "build/libarchive.sh"
+bash "build/brotli.sh"
+bash "build/bzip2.sh"
+bash "build/freetype.sh"
+bash "build/boost.sh"
+bash "build/targets.sh"
cd "${dir}"
diff --git a/fuzzing/scripts/build/brotli.sh b/fuzzing/scripts/build/brotli.sh
new file mode 100644
index 0000000..275021a
--- /dev/null
+++ b/fuzzing/scripts/build/brotli.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+set -euxo pipefail
+
+# Copyright 2019 by
+# Armin Hasitzka.
+#
+# This file is part of the FreeType project, and may only be used, modified,
+# and distributed under the terms of the FreeType project license,
+# LICENSE.TXT. By continuing to use, modify, or distribute this file you
+# indicate that you have read the license and understand and accept it
+# fully.
+
+dir="${PWD}"
+cd $( dirname $( readlink -f "${0}" ) ) # go to `/fuzzing/scripts/build'
+
+path_to_src=$( readlink -f "../../../external/brotli" )
+path_to_build="${path_to_src}/build"
+
+if [[ "${#}" == "0" || "${1}" != "--no-init" ]]; then
+
+ git submodule update --init "${path_to_src}"
+
+ cd "${path_to_src}"
+
+ git clean -dfqx
+ git reset --hard
+ git rev-parse HEAD
+
+ mkdir "${path_to_build}" && cd "${path_to_build}"
+
+ cmake -DCMAKE_BUILD_TYPE=Release ..
+fi
+
+if [[ -d "${path_to_build}" ]]; then
+ cd "${path_to_build}"
+ make -j$( nproc )
+fi
+
+cd "${dir}"
diff --git a/fuzzing/scripts/build/freetype.sh b/fuzzing/scripts/build/freetype.sh
index 221798d..8a77eb5 100644
--- a/fuzzing/scripts/build/freetype.sh
+++ b/fuzzing/scripts/build/freetype.sh
@@ -36,6 +36,9 @@
export BZIP2_CFLAGS="-I../bzip2"
export BZIP2_LIBS="-l../bzip2/libbz2.a"
+ export BROTLI_CFLAGS="-I../brotli/c/include"
+ export BROTLI_LIBS="-l../brotli/build/libbrotlidec-static.a"
+
# Having additional libraries is pain since they have to be linked
# statically for OSS-Fuzz. Should additional libraries be required, they
# have to be linked properly in `fuzzing/src/fuzzers/CMakeLists.txt'.
@@ -43,11 +46,11 @@
sh configure \
--enable-static \
--disable-shared \
+ --with-brotli \
--with-bzip2 \
--without-harfbuzz \
--without-png \
- --without-zlib \
- --without-brotli
+ --without-zlib
fi
cd "${path_to_freetype}"
diff --git a/fuzzing/scripts/custom-build.sh b/fuzzing/scripts/custom-build.sh
index 13692f0..a2b9509 100755
--- a/fuzzing/scripts/custom-build.sh
+++ b/fuzzing/scripts/custom-build.sh
@@ -388,6 +388,7 @@
fi
bash "build/libarchive.sh"
+bash "build/brotli.sh"
bash "build/bzip2.sh"
bash "build/freetype.sh"
bash "build/boost.sh"
diff --git a/fuzzing/scripts/travis-ci/regression-suite.sh b/fuzzing/scripts/travis-ci/regression-suite.sh
index a88d652..744ef03 100644
--- a/fuzzing/scripts/travis-ci/regression-suite.sh
+++ b/fuzzing/scripts/travis-ci/regression-suite.sh
@@ -27,11 +27,12 @@
cd ..
-bash build/libarchive.sh
-bash build/bzip2.sh
-bash build/freetype.sh
-bash build/boost.sh
-bash build/targets.sh
+bash "build/libarchive.sh"
+bash "build/brotli.sh"
+bash "build/bzip2.sh"
+bash "build/freetype.sh"
+bash "build/boost.sh"
+bash "build/targets.sh"
cd ../build
diff --git a/fuzzing/src/driver/CMakeLists.txt b/fuzzing/src/driver/CMakeLists.txt
index f4394d9..83b124c 100644
--- a/fuzzing/src/driver/CMakeLists.txt
+++ b/fuzzing/src/driver/CMakeLists.txt
@@ -21,7 +21,8 @@
"${LIBARCHIVE_STATIC_LIBRARY}"
fuzztargets
"${FREETYPE_STATIC_LIBRARY}"
- "${BZIP2_STATIC_LIBRARY}")
+ "${BZIP2_STATIC_LIBRARY}"
+ "${BROTLI_STATIC_LIBRARY}")
if("${LOGGER_NAME}" STREQUAL "LOGGER_GLOG")
target_compile_definitions(driver PRIVATE "LOGGER_GLOG")
diff --git a/fuzzing/src/fuzzers/CMakeLists.txt b/fuzzing/src/fuzzers/CMakeLists.txt
index d48619a..7f85684 100644
--- a/fuzzing/src/fuzzers/CMakeLists.txt
+++ b/fuzzing/src/fuzzers/CMakeLists.txt
@@ -45,7 +45,8 @@
PRIVATE
"${LIBARCHIVE_STATIC_LIBRARY}"
"${FREETYPE_STATIC_LIBRARY}"
- "${BZIP2_STATIC_LIBRARY}")
+ "${BZIP2_STATIC_LIBRARY}"
+ "${BROTLI_STATIC_LIBRARY}")
# `-fsanitize=fuzzer' or `-lFuzzingEngine' cannot be set earlier since CMake
# defines a main function when testing the compiler. Clang (obviously)