2020-11-06 12:59:19 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2023-03-19 20:47:30 -04:00
|
|
|
usage() {
|
|
|
|
cat <<-EOF
|
|
|
|
Usage: $(basename $0) [OPTION…] REPO_URL COMMIT SUBDIR PREPARE
|
|
|
|
|
|
|
|
Check out and install a meson project
|
|
|
|
|
|
|
|
Options:
|
|
|
|
-Dkey=val Option to pass on to meson
|
|
|
|
|
|
|
|
EOF
|
|
|
|
}
|
2020-11-06 12:59:19 -05:00
|
|
|
|
|
|
|
MESON_OPTIONS=()
|
|
|
|
|
|
|
|
while [[ $1 =~ ^-D ]]; do
|
|
|
|
MESON_OPTIONS+=( "$1" )
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2023-03-19 20:47:30 -04:00
|
|
|
if [[ $# -lt 4 ]]; then
|
|
|
|
usage
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-11-06 12:59:19 -05:00
|
|
|
REPO_URL="$1"
|
|
|
|
COMMIT="$2"
|
|
|
|
SUBDIR="$3"
|
|
|
|
PREPARE="$4"
|
|
|
|
|
2023-03-20 20:00:07 -04:00
|
|
|
CHECKOUT_DIR=$(mktemp --directory)
|
|
|
|
trap "rm -rf $CHECKOUT_DIR" EXIT
|
2020-11-06 12:59:19 -05:00
|
|
|
|
2023-03-20 20:00:07 -04:00
|
|
|
git clone --depth 1 "$REPO_URL" -b "$COMMIT" "$CHECKOUT_DIR"
|
|
|
|
|
|
|
|
pushd "$CHECKOUT_DIR/$SUBDIR"
|
2020-11-06 12:59:19 -05:00
|
|
|
sh -c "$PREPARE"
|
2023-03-19 20:40:43 -04:00
|
|
|
meson setup --prefix=/usr _build "${MESON_OPTIONS[@]}"
|
2021-08-04 21:46:53 -04:00
|
|
|
meson install -C _build
|
2020-11-06 12:59:19 -05:00
|
|
|
popd
|