actions-rust-cross/strip-binary.sh
2023-12-10 11:21:49 -06:00

43 lines
911 B
Bash
Executable File

set -e
set -x
TARGET=$1
did_strip=""
strip_binary () {
if [[ $( uname -s ) =~ "Darwin" ]]; then
stripped=$(
find "$1" -maxdepth 1 -type f -perm +111 | while read exe; do
strip "$exe"
echo "stripped $exe"
done
)
else
stripped=$(
find "$1" -maxdepth 1 -type f -executable | while read exe; do
strip "$exe"
echo "stripped $exe"
done
)
fi
if [ -z "$stripped" ]; then
echo "Could not find any binaries to strip in $1"
else
did_strip="true"
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 "$did_strip" ]; then
echo "No binaries were stripped"
exit 1
fi