Make strip script strip all binaries under target

If there were both debug & release dirs it would only strip one binary, and if
the debug dir had no binary at all it would error, even if the release dir had
one.
This commit is contained in:
Dave Rolsky 2023-04-21 22:13:53 -05:00
parent 91d78d9182
commit 356ca41f7d
No known key found for this signature in database
2 changed files with 27 additions and 20 deletions

View File

@ -1,3 +1,10 @@
## 0.0.6 - 2023-04-21
- When the `strip` parameter was true, stripping binaries could fail if there
were both `target/*/debug` and `target/*/release` directories present and
the `debug` directory didn't have a binary. Now it will strip all binaries
it finds under `target`.
## 0.0.5 - 2023-03-19 ## 0.0.5 - 2023-03-19
- Fix use of `dtolnay/rust-toolchain` action to allow passing a `toolchain` - Fix use of `dtolnay/rust-toolchain` action to allow passing a `toolchain`

View File

@ -2,32 +2,32 @@ set -e
set -x set -x
TARGET=$1 TARGET=$1
stripped=""
strip_binary () {
if [[ $( uname -s ) =~ "Darwin" ]]; then
EXE=$( find "$1" -maxdepth 1 -type f -perm +111 )
else
EXE=$( find "$1" -maxdepth 1 -type f -executable )
fi
if [ -z "$EXE" ]; then
echo "Could not find a binary to strip in $1"
else
strip "$EXE"
stripped="$EXE"
fi
}
DIR=""
for type in debug release; do for type in debug release; do
if [ -d "target/$TARGET/$type" ]; then if [ -d "target/$TARGET/$type" ]; then
DIR="target/$TARGET/$type" strip_binary "target/$TARGET/$type"
break
elif [ -d "target/$type" ]; then elif [ -d "target/$type" ]; then
DIR="target/$type" strip_binary "target/$type"
break
fi fi
done done
if [ -z "$DIR" ]; then if [ -z "$stripped" ]; then
echo "Could not find directory with binary in it under target/" echo "No binaries were stripped"
exit 1 exit 1
fi fi
if [[ $( uname -s ) =~ "Darwin" ]]; then
EXE=$( find "$DIR" -maxdepth 1 -type f -perm +111 )
else
EXE=$( find "$DIR" -maxdepth 1 -type f -executable )
fi
if [ -z "$EXE" ]; then
echo "Could not find a binary to strip in $DIR"
exit 2
fi
strip "$EXE"