From 32a5a16dfd652e7f46473877b58a971414fe5e24 Mon Sep 17 00:00:00 2001 From: Bryce Berger Date: Thu, 5 Jun 2025 14:44:05 -0400 Subject: [PATCH] compare_all.sh: get difft binary using `cargo metadata` I have cargo configured to have a global target directory (in my case, at /tmp/cargo). The output directory for cargo builds is not guarunteed to be at ./target. This could alternatively be solved by the user with strange defaults (me) making a symlink like `ln -s /tmp/cargo ./target`, which doesn't require having `jq` installed. --- sample_files/compare_all.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sample_files/compare_all.sh b/sample_files/compare_all.sh index a993a5a5d..90c68f090 100755 --- a/sample_files/compare_all.sh +++ b/sample_files/compare_all.sh @@ -16,6 +16,7 @@ set -e echo "==> Building difftastic" cargo build --release +difft_bin=$(cargo metadata --format-version 1 | jq -r '.target_directory')/release/difft # Set language so we expand globs in a consistent order regardless of # locale (e.g. on GitHub actions). @@ -28,7 +29,7 @@ for before_f in sample_files/*_1.*; do after_f=${before_f/_1/_2} echo "$before_f $after_f" - difft_out=$(DFT_WIDTH=180 ./target/release/difft --color=always "$before_f" "$after_f" | md5sum) + difft_out=$(DFT_WIDTH=180 $difft_bin --color=always "$before_f" "$after_f" | md5sum) echo "$difft_out" echo done | tee sample_files/compare.result