diff --git a/install.sh b/install.sh index 7390ee2..3af7fb4 100755 --- a/install.sh +++ b/install.sh @@ -40,16 +40,21 @@ if ! (cd "$SCRIPT_DIR" && cargo build --release); then exit 1 fi -# Find the binary — handles custom target triples (e.g., CARGO_BUILD_TARGET -# puts it in target//release/ instead of target/release/) -BINARY="$SCRIPT_DIR/target/release/$BINARY_NAME" +# Find the binary — respects CARGO_TARGET_DIR, custom target triples, etc. +# Use cargo metadata as the source of truth for the target directory. +TARGET_DIR=$(cd "$SCRIPT_DIR" && cargo metadata --format-version 1 --no-deps 2>/dev/null | jq -r '.target_directory' 2>/dev/null) || true +TARGET_DIR="${TARGET_DIR:-$SCRIPT_DIR/target}" + +BINARY="$TARGET_DIR/release/$BINARY_NAME" if [[ ! -f "$BINARY" ]]; then - BINARY=$(find "$SCRIPT_DIR/target" -name "$BINARY_NAME" -type f -path "*/release/*" ! -name "*.d" 2>/dev/null | head -1) + # Fall back to searching (handles custom target triples like target//release/) + BINARY=$(find "$TARGET_DIR" -name "$BINARY_NAME" -type f -path "*/release/*" ! -name "*.d" 2>/dev/null | head -1) fi if [[ -z "${BINARY:-}" || ! -f "$BINARY" ]]; then echo "ERROR: Build succeeded but binary not found." - echo " Searched: $SCRIPT_DIR/target/*/release/$BINARY_NAME" - echo " Contents: $(ls "$SCRIPT_DIR/target/release/" 2>/dev/null || echo '(no target/release/)')" + echo " Target dir: $TARGET_DIR" + echo " Searched: $TARGET_DIR/*/release/$BINARY_NAME" + echo " Contents: $(ls "$TARGET_DIR/release/" 2>/dev/null || echo '(empty or missing)')" exit 1 fi echo "[ok] Built: $(ls -lh "$BINARY" | awk '{print $5}')"