]> git.proxmox.com Git - libgit2.git/blame - ci/build.sh
Merge https://salsa.debian.org/debian/libgit2 into proxmox/bullseye
[libgit2.git] / ci / build.sh
CommitLineData
6c7cee42
RD
1#!/usr/bin/env bash
2#
3# Environment variables:
4#
5# SOURCE_DIR: Set to the directory of the libgit2 source (optional)
6# If not set, it will be derived relative to this script.
7
8set -e
9
10SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
11BUILD_DIR=$(pwd)
22a2d3d5
UG
12BUILD_PATH=${BUILD_PATH:=$PATH}
13CMAKE=$(which cmake)
14CMAKE_GENERATOR=${CMAKE_GENERATOR:-Unix Makefiles}
15
16if [[ "$(uname -s)" == MINGW* ]]; then
17 BUILD_PATH=$(cygpath "$BUILD_PATH")
18fi
6c7cee42
RD
19
20indent() { sed "s/^/ /"; }
21
22echo "Source directory: ${SOURCE_DIR}"
23echo "Build directory: ${BUILD_DIR}"
24echo ""
ac3d33df
JK
25
26if [ "$(uname -s)" = "Darwin" ]; then
27 echo "macOS version:"
28 sw_vers | indent
29fi
30
31if [ -f "/etc/debian_version" ]; then
32 echo "Debian version:"
22a2d3d5 33 (source /etc/lsb-release && echo "${DISTRIB_DESCRIPTION}") | indent
ac3d33df
JK
34fi
35
c25aa7cd
PP
36CORES=$(getconf _NPROCESSORS_ONLN || true)
37echo "Number of cores: ${CORES:-(Unknown)}"
38
ac3d33df 39echo "Kernel version:"
6c7cee42 40uname -a 2>&1 | indent
ac3d33df 41
6c7cee42 42echo "CMake version:"
22a2d3d5
UG
43env PATH="${BUILD_PATH}" "${CMAKE}" --version 2>&1 | indent
44
45if test -n "${CC}"; then
46 echo "Compiler version:"
47 "${CC}" --version 2>&1 | indent
48fi
49echo "Environment:"
50if test -n "${CC}"; then
51 echo "CC=${CC}" | indent
52fi
53if test -n "${CFLAGS}"; then
54 echo "CFLAGS=${CFLAGS}" | indent
55fi
6c7cee42
RD
56echo ""
57
58echo "##############################################################################"
59echo "## Configuring build environment"
60echo "##############################################################################"
61
ad5611d8 62echo "${CMAKE}" -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS} -S \"${SOURCE_DIR}\"
22a2d3d5 63env 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}"
6c7cee42
RD
64
65echo ""
66echo "##############################################################################"
67echo "## Building libgit2"
68echo "##############################################################################"
69
c25aa7cd
PP
70# Determine parallelism; newer cmake supports `--build --parallel` but
71# we cannot yet rely on that.
ad5611d8 72if [ "${CMAKE_GENERATOR}" = "Unix Makefiles" -a "${CORES}" != "" -a "${CMAKE_BUILD_OPTIONS}" = "" ]; then
c25aa7cd
PP
73 BUILDER=(make -j ${CORES})
74else
ad5611d8 75 BUILDER=("${CMAKE}" --build . ${CMAKE_BUILD_OPTIONS})
c25aa7cd
PP
76fi
77
ad5611d8 78echo "${BUILDER[@]}"
c25aa7cd 79env PATH="${BUILD_PATH}" "${BUILDER[@]}"