2020-11-20 18:13:46 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2023-05-19 15:52:52 +00:00
|
|
|
usage() {
|
|
|
|
cat <<-EOF
|
|
|
|
Usage: $(basename $0) [OPTION…] REPO_URL COMMIT
|
|
|
|
|
|
|
|
Check out and install a meson project
|
|
|
|
|
|
|
|
Options:
|
|
|
|
-Dkey=val Option to pass on to meson
|
|
|
|
--subdir Build subdirectory instead of whole project
|
|
|
|
--prepare Script to run before build
|
|
|
|
|
|
|
|
-h, --help Display this help
|
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
TEMP=$(getopt \
|
|
|
|
--name=$(basename $0) \
|
|
|
|
--options='D:h' \
|
|
|
|
--longoptions='subdir:' \
|
|
|
|
--longoptions='prepare:' \
|
|
|
|
--longoptions='help' \
|
|
|
|
-- "$@")
|
|
|
|
|
|
|
|
eval set -- "$TEMP"
|
|
|
|
unset TEMP
|
2020-11-20 18:13:46 +00:00
|
|
|
|
|
|
|
MESON_OPTIONS=()
|
2023-05-19 15:52:52 +00:00
|
|
|
SUBDIR=.
|
|
|
|
PREPARE=:
|
2020-11-20 18:13:46 +00:00
|
|
|
|
2023-05-19 15:52:52 +00:00
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
-D)
|
|
|
|
MESON_OPTIONS+=( -D$2 )
|
|
|
|
shift 2
|
|
|
|
;;
|
2020-11-20 18:13:46 +00:00
|
|
|
|
2023-05-19 15:52:52 +00:00
|
|
|
--subdir)
|
|
|
|
SUBDIR=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
|
|
|
|
|
|
|
--prepare)
|
|
|
|
PREPARE=$2
|
|
|
|
shift 2
|
|
|
|
;;
|
2020-11-20 18:13:46 +00:00
|
|
|
|
2023-05-19 15:52:52 +00:00
|
|
|
-h|--help)
|
|
|
|
usage
|
|
|
|
exit 0
|
|
|
|
;;
|
2020-11-20 18:13:46 +00:00
|
|
|
|
2023-05-19 15:52:52 +00:00
|
|
|
--)
|
|
|
|
shift
|
|
|
|
break
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
2021-01-21 18:14:23 +00:00
|
|
|
|
2023-05-19 15:52:52 +00:00
|
|
|
if [[ $# -lt 2 ]]; then
|
|
|
|
usage
|
|
|
|
exit 1
|
2021-01-21 18:14:23 +00:00
|
|
|
fi
|
|
|
|
|
2023-05-19 15:52:52 +00:00
|
|
|
REPO_URL="$1"
|
|
|
|
COMMIT="$2"
|
|
|
|
|
|
|
|
CHECKOUT_DIR=$(mktemp --directory)
|
|
|
|
trap "rm -rf $CHECKOUT_DIR" EXIT
|
|
|
|
|
|
|
|
git clone --depth 1 "$REPO_URL" -b "$COMMIT" "$CHECKOUT_DIR"
|
|
|
|
|
|
|
|
pushd "$CHECKOUT_DIR/$SUBDIR"
|
|
|
|
sh -c "$PREPARE"
|
|
|
|
meson setup --prefix=/usr _build "${MESON_OPTIONS[@]}"
|
2021-08-05 12:57:09 +00:00
|
|
|
meson install -C _build
|
2020-11-20 18:13:46 +00:00
|
|
|
popd
|