Files
libgit2/azure-pipelines/build.sh
lhchavez 6a917c0439 Add CI support for Memory and UndefinedBehavior Sanitizers
This change adds two new build targets: MSan and UBSan. This is because
even though OSS-Fuzz is great and adds a lot of coverage, it only does
that for the fuzz targets, so the rest of the codebase is not
necessarily run with the Sanitizers ever :( So this change makes sure
that MSan/UBSan warnings don't make it into the codebase.

As part of this change, the Ubuntu focal container is introduced. It
builds mbedTLS and libssh2 as debug libraries into /usr/local and as
MSan-enabled libraries into /usr/local/msan. This latter part is needed
because MSan requires the binary and all its dependent libraries to be
built with MSan support so that memory allocations and deallocations are
tracked correctly to avoid false positives.
2020-07-09 15:13:34 -07:00

68 lines
1.9 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Environment variables:
#
# SOURCE_DIR: Set to the directory of the libgit2 source (optional)
# If not set, it will be derived relative to this script.
set -e
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
BUILD_DIR=$(pwd)
BUILD_PATH=${BUILD_PATH:=$PATH}
CMAKE=$(which cmake)
CMAKE_GENERATOR=${CMAKE_GENERATOR:-Unix Makefiles}
if [[ "$(uname -s)" == MINGW* ]]; then
BUILD_PATH=$(cygpath "$BUILD_PATH")
fi
indent() { sed "s/^/ /"; }
echo "Source directory: ${SOURCE_DIR}"
echo "Build directory: ${BUILD_DIR}"
echo ""
if [ "$(uname -s)" = "Darwin" ]; then
echo "macOS version:"
sw_vers | indent
fi
if [ -f "/etc/debian_version" ]; then
echo "Debian version:"
(source /etc/lsb-release && echo "${DISTRIB_DESCRIPTION}") | indent
fi
echo "Kernel version:"
uname -a 2>&1 | indent
echo "CMake version:"
env PATH="${BUILD_PATH}" "${CMAKE}" --version 2>&1 | indent
if test -n "${CC}"; then
echo "Compiler version:"
"${CC}" --version 2>&1 | indent
fi
echo "Environment:"
if test -n "${CC}"; then
echo "CC=${CC}" | indent
fi
if test -n "${CFLAGS}"; then
echo "CFLAGS=${CFLAGS}" | indent
fi
echo ""
echo "##############################################################################"
echo "## Configuring build environment"
echo "##############################################################################"
echo cmake -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS} -S \"${SOURCE_DIR}\"
env PATH="${BUILD_PATH}" "${CMAKE}" -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G "${CMAKE_GENERATOR}" ${CMAKE_OPTIONS} -S "${SOURCE_DIR}"
echo ""
echo "##############################################################################"
echo "## Building libgit2"
echo "##############################################################################"
env PATH="${BUILD_PATH}" "${CMAKE}" --build .