actions-rust-cross/strip-binary.sh
Dave Rolsky 356ca41f7d
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.
2023-04-21 22:39:30 -05:00

34 lines
662 B
Bash
Executable File

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
}
for type in debug release; do
if [ -d "target/$TARGET/$type" ]; then
strip_binary "target/$TARGET/$type"
elif [ -d "target/$type" ]; then
strip_binary "target/$type"
fi
done
if [ -z "$stripped" ]; then
echo "No binaries were stripped"
exit 1
fi