Last active
December 5, 2024 17:32
-
-
Save dmgolembiowski/f9d907898a2c5c2161df3bd1be5f7cbd to your computer and use it in GitHub Desktop.
For first-time cargo release builds that one prefers to have symlinked rather than copied
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | |
# SYMLINK_DIR= | |
if [ "$( env | grep -Ec "^SYMLINK_DIR=" )" -ne 1 ]; then | |
echo "SYMLINK_DIR is not set" | |
echo "Defaulting to $SCRIPT_DIR" | |
SYMLINK_DIR=$SCRIPT_DIR | |
else | |
SYMLINK_DIR=$( env | grep -E "^SYMLINK_DIR=" | cut -d "=" -f 2 ) | |
fi | |
$SCRIPT_DIR/cargo build --workspace --release | |
CARGO_EXIT_CODE=$? | |
if [ $CARGO_EXIT_CODE -ne 0 ]; then | |
exit $CARGO_EXIT_CODE | |
fi | |
for file in target/release/*; do | |
if [[ -x "$file" && ! -d "$file" ]]; then | |
echo "ln -s $PWD/$file $SYMLINK_DIR/$(basename $file)" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To use, copy this script to your cargo bin directory and ensure it is executable