2018-02-04 19:14:38 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Various utility functions used through CI.
|
2016-09-06 02:08:46 +02:00
|
|
|
|
2018-02-10 17:30:35 +02:00
|
|
|
# Finds Cargo's `OUT_DIR` directory from the most recent build.
|
|
|
|
#
|
|
|
|
# This requires one parameter corresponding to the target directory
|
|
|
|
# to search for the build output.
|
|
|
|
cargo_out_dir() {
|
|
|
|
# This works by finding the most recent stamp file, which is produced by
|
|
|
|
# every ripgrep build.
|
|
|
|
target_dir="$1"
|
|
|
|
find "$target_dir" -name ripgrep-stamp -print0 \
|
|
|
|
| xargs -0 ls -t \
|
|
|
|
| head -n1 \
|
|
|
|
| xargs dirname
|
|
|
|
}
|
|
|
|
|
2016-09-06 02:08:46 +02:00
|
|
|
host() {
|
|
|
|
case "$TRAVIS_OS_NAME" in
|
|
|
|
linux)
|
|
|
|
echo x86_64-unknown-linux-gnu
|
|
|
|
;;
|
|
|
|
osx)
|
|
|
|
echo x86_64-apple-darwin
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
architecture() {
|
2018-02-04 19:14:38 +02:00
|
|
|
case "$TARGET" in
|
2017-12-17 15:41:51 +02:00
|
|
|
x86_64-*)
|
2016-09-06 02:08:46 +02:00
|
|
|
echo amd64
|
|
|
|
;;
|
2017-12-17 15:41:51 +02:00
|
|
|
i686-*|i586-*|i386-*)
|
2016-09-06 02:08:46 +02:00
|
|
|
echo i386
|
|
|
|
;;
|
|
|
|
arm*-unknown-linux-gnueabihf)
|
|
|
|
echo armhf
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
die "architecture: unexpected target $TARGET"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
2017-12-17 15:41:51 +02:00
|
|
|
|
2018-02-06 22:53:17 +02:00
|
|
|
gcc_prefix() {
|
|
|
|
case "$(architecture)" in
|
|
|
|
armhf)
|
|
|
|
echo arm-linux-gnueabihf-
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2019-04-25 16:49:59 +02:00
|
|
|
is_musl() {
|
|
|
|
case "$TARGET" in
|
|
|
|
*-musl) return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2018-02-06 22:53:17 +02:00
|
|
|
is_x86() {
|
|
|
|
case "$(architecture)" in
|
|
|
|
amd64|i386) return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2019-04-25 16:49:59 +02:00
|
|
|
is_x86_64() {
|
|
|
|
case "$(architecture)" in
|
|
|
|
amd64) return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
2018-02-06 22:53:17 +02:00
|
|
|
is_arm() {
|
|
|
|
case "$(architecture)" in
|
|
|
|
armhf) return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
is_linux() {
|
|
|
|
case "$TRAVIS_OS_NAME" in
|
|
|
|
linux) return 0 ;;
|
|
|
|
*) return 1 ;;
|
2017-12-17 15:41:51 +02:00
|
|
|
esac
|
|
|
|
}
|
2018-02-10 17:30:35 +02:00
|
|
|
|
|
|
|
is_osx() {
|
|
|
|
case "$TRAVIS_OS_NAME" in
|
|
|
|
osx) return 0 ;;
|
|
|
|
*) return 1 ;;
|
|
|
|
esac
|
|
|
|
}
|
2019-04-25 16:49:59 +02:00
|
|
|
|
|
|
|
builder() {
|
|
|
|
if is_musl && is_x86_64; then
|
2020-11-09 14:25:41 +02:00
|
|
|
cargo install cross
|
2019-04-25 16:49:59 +02:00
|
|
|
echo "cross"
|
|
|
|
else
|
|
|
|
echo "cargo"
|
|
|
|
fi
|
|
|
|
}
|