2018-06-13 20:12:52 +02:00
|
|
|
#!/usr/bin/env bash
|
2016-11-25 21:20:17 +01:00
|
|
|
|
|
|
|
#
|
|
|
|
# Configure, build and install ninja
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
2018-06-05 04:58:54 +02:00
|
|
|
# build-and-install-ninja.sh [-python /path/to/bin/python]
|
2016-11-25 21:20:17 +01:00
|
|
|
|
|
|
|
set -e
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
PYTHON=python
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
case "$1" in
|
|
|
|
-python)
|
|
|
|
PYTHON=$2
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: Usage: ${0##*/} [-python /path/to/bin/python]"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2022-05-18 17:45:56 +02:00
|
|
|
if [[ -z "${NINJA_VERSION}" ]]; then
|
|
|
|
echo >&2 'error: NINJA_VERSION env. variable must be set to a non-empty value'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-11-25 21:20:17 +01:00
|
|
|
# Download
|
2022-05-18 22:34:46 +02:00
|
|
|
url="https://github.com/ninja-build/ninja/archive/v${NINJA_VERSION}.tar.gz"
|
2022-05-18 17:45:56 +02:00
|
|
|
|
2021-08-06 01:17:47 +02:00
|
|
|
curl --connect-timeout 30 \
|
|
|
|
--max-time 10 \
|
|
|
|
--retry 5 \
|
|
|
|
--retry-delay 10 \
|
|
|
|
--retry-max-time 30 \
|
2022-05-18 22:34:46 +02:00
|
|
|
-# -o ninja.tar.gz -LO "$url"
|
2021-08-06 01:17:47 +02:00
|
|
|
|
2016-11-25 21:20:17 +01:00
|
|
|
mkdir ninja
|
|
|
|
tar -xzvf ./ninja.tar.gz --strip-components=1 -C ./ninja
|
|
|
|
|
|
|
|
# Configure, build and install
|
|
|
|
pushd ./ninja
|
|
|
|
echo "Configuring ninja using [$PYTHON]"
|
|
|
|
$PYTHON ./configure.py --bootstrap && ./ninja
|
|
|
|
cp ./ninja /usr/bin/
|
|
|
|
popd
|
|
|
|
|
|
|
|
# Clean
|
|
|
|
rm -rf ./ninja*
|
|
|
|
|