on master help sign in
Simplify cargo-target-dir extraction
ea2faf4David Peter
tests/benchmarks/run-benchmarks.sh+9−9
@@ -8,18 +8,18 @@ if ! command -v hyperfine > /dev/null 2>&1; then
8 exit 1
8 exit 1
9fi
9fi
10
10
11−# Determine the target directories.
11+# Check that jq is installed.
12−get_target_dir() {
12+if ! command -v jq > /dev/null 2>&1; then
13− if [[ -f "$HOME/.cargo/config" ]]; then
13+ echo "'jq' does not seem to be installed."
14− grep 'target-dir[[:space:]]*=' "$HOME/.cargo/config" \
14+ echo "You can get it here: https://stedolan.github.io/jq"
15− | sed 's/^[[:space:]]*target-dir[[:space:]]*=//; s/^[[:space:]]*"//; s/"[[:space:]]*$//' \
15+ exit 1
16− && return 0
17− fi
16+fi
18
17
19− echo "../../target"
18+get_cargo_target_dir() {
19+ cargo metadata --no-deps --format-version 1 | jq -r .target_directory
20}
20}
21
21
22−TARGET_DIR="$(get_target_dir)"
22+TARGET_DIR="$(get_cargo_target_dir)"
23TARGET_DEBUG="${TARGET_DIR}/debug/bat"
23TARGET_DEBUG="${TARGET_DIR}/debug/bat"
24TARGET_RELEASE="${TARGET_DIR}/release/bat"
24TARGET_RELEASE="${TARGET_DIR}/release/bat"
25
25