Skip to content

Commit b6ca894

Browse files
committed
Simplify cargo-target-dir extraction
1 parent 47149fc commit b6ca894

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

tests/benchmarks/run-benchmarks.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@ if ! command -v hyperfine > /dev/null 2>&1; then
88
exit 1
99
fi
1010

11-
# Determine the target directories.
12-
get_target_dir() {
13-
if [[ -f "$HOME/.cargo/config" ]]; then
14-
grep 'target-dir[[:space:]]*=' "$HOME/.cargo/config" \
15-
| sed 's/^[[:space:]]*target-dir[[:space:]]*=//; s/^[[:space:]]*"//; s/"[[:space:]]*$//' \
16-
&& return 0
17-
fi
11+
# Check that jq is installed.
12+
if ! command -v jq > /dev/null 2>&1; then
13+
echo "'jq' does not seem to be installed."
14+
echo "You can get it here: https://stedolan.github.io/jq"
15+
exit 1
16+
fi
1817

19-
echo "../../target"
18+
get_cargo_target_dir() {
19+
cargo metadata --no-deps --format-version 1 | jq -r .target_directory
2020
}
2121

22-
TARGET_DIR="$(get_target_dir)"
22+
TARGET_DIR="$(get_cargo_target_dir)"
2323
TARGET_DEBUG="${TARGET_DIR}/debug/bat"
2424
TARGET_RELEASE="${TARGET_DIR}/release/bat"
2525

0 commit comments

Comments
 (0)