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:
parent
91d78d9182
commit
356ca41f7d
@ -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
|
||||
|
||||
- Fix use of `dtolnay/rust-toolchain` action to allow passing a `toolchain`
|
||||
|
||||
@ -2,32 +2,32 @@ set -e
|
||||
set -x
|
||||
|
||||
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
|
||||
if [ -d "target/$TARGET/$type" ]; then
|
||||
DIR="target/$TARGET/$type"
|
||||
break
|
||||
strip_binary "target/$TARGET/$type"
|
||||
elif [ -d "target/$type" ]; then
|
||||
DIR="target/$type"
|
||||
break
|
||||
strip_binary "target/$type"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$DIR" ]; then
|
||||
echo "Could not find directory with binary in it under target/"
|
||||
if [ -z "$stripped" ]; then
|
||||
echo "No binaries were stripped"
|
||||
exit 1
|
||||
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"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user