summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Peter <mail@david-peter.de>2021-11-22 20:49:10 +0100
committerDavid Peter <sharkdp@users.noreply.github.com>2021-11-23 08:14:49 +0100
commitea2faf45e4fc772d54d420bd886bc8d046a48acf (patch)
treebea5766bd611577e23dd6f99736058c22a55aad6
parent1822c981da238e9629157fb0548a96de84f6ac36 (diff)
Simplify cargo-target-dir extraction
-rwxr-xr-xtests/benchmarks/run-benchmarks.sh18
1 files changed, 9 insertions, 9 deletions
diff --git a/tests/benchmarks/run-benchmarks.sh b/tests/benchmarks/run-benchmarks.sh
index 3be2aac5..690a78aa 100755
--- a/tests/benchmarks/run-benchmarks.sh
+++ b/tests/benchmarks/run-benchmarks.sh
@@ -8,18 +8,18 @@ if ! command -v hyperfine > /dev/null 2>&1; then
exit 1
fi
-# Determine the target directories.
-get_target_dir() {
- if [[ -f "$HOME/.cargo/config" ]]; then
- grep 'target-dir[[:space:]]*=' "$HOME/.cargo/config" \
- | sed 's/^[[:space:]]*target-dir[[:space:]]*=//; s/^[[:space:]]*"//; s/"[[:space:]]*$//' \
- && return 0
- fi
+# Check that jq is installed.
+if ! command -v jq > /dev/null 2>&1; then
+ echo "'jq' does not seem to be installed."
+ echo "You can get it here: https://stedolan.github.io/jq"
+ exit 1
+fi
- echo "../../target"
+get_cargo_target_dir() {
+ cargo metadata --no-deps --format-version 1 | jq -r .target_directory
}
-TARGET_DIR="$(get_target_dir)"
+TARGET_DIR="$(get_cargo_target_dir)"
TARGET_DEBUG="${TARGET_DIR}/debug/bat"
TARGET_RELEASE="${TARGET_DIR}/release/bat"