2020-11-20 13:13:46 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
if [[ $# -lt 3 ]]; then
|
|
|
|
echo Usage: $0 [options] [repo-url] [commit] [subdir]
|
|
|
|
echo Options:
|
|
|
|
echo -Dkey=val
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
MESON_OPTIONS=()
|
|
|
|
|
|
|
|
while [[ $1 =~ ^-D ]]; do
|
|
|
|
MESON_OPTIONS+=( "$1" )
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
REPO_URL="$1"
|
2021-01-21 13:14:23 -05:00
|
|
|
TAG_OR_BRANCH="$2"
|
2020-11-20 13:13:46 -05:00
|
|
|
SUBDIR="$3"
|
2021-01-21 13:14:23 -05:00
|
|
|
COMMIT="$4"
|
2020-11-20 13:13:46 -05:00
|
|
|
|
|
|
|
REPO_DIR="$(basename ${REPO_URL%.git})"
|
|
|
|
|
2021-01-21 13:14:23 -05:00
|
|
|
git clone --depth 1 "$REPO_URL" -b "$TAG_OR_BRANCH"
|
2020-11-20 13:13:46 -05:00
|
|
|
pushd "$REPO_DIR"
|
|
|
|
pushd "$SUBDIR"
|
2021-01-21 13:14:23 -05:00
|
|
|
|
|
|
|
if [ ! -z "$COMMIT" ]; then
|
|
|
|
git fetch origin "$COMMIT"
|
|
|
|
git checkout "$COMMIT"
|
|
|
|
fi
|
|
|
|
|
2020-11-20 13:13:46 -05:00
|
|
|
meson --prefix=/usr _build "${MESON_OPTIONS[@]}"
|
2021-08-05 08:57:09 -04:00
|
|
|
meson install -C _build
|
2020-11-20 13:13:46 -05:00
|
|
|
popd
|
|
|
|
popd
|
|
|
|
rm -rf "$REPO_DIR"
|