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"
|
|
|
|
|
|
|
|
REPO_DIR="$(basename ${REPO_URL%.git})"
|
|
|
|
|
|
|
|
git clone --depth 1 "$REPO_URL" -b "$COMMIT"
|
|
|
|
pushd "$REPO_DIR"
|
|
|
|
pushd "$SUBDIR"
|
|
|
|
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
|
|
|
|
popd
|
|
|
|
rm -rf "$REPO_DIR"
|