Fix stripping and test it

This commit is contained in:
Dave Rolsky
2023-03-19 11:03:38 -04:00
parent 2bfd2f169a
commit d1d76ade32
4 changed files with 100 additions and 24 deletions

33
strip-binary.sh Executable file
View File

@@ -0,0 +1,33 @@
set -e
set -x
TARGET=$1
DIR=""
for type in debug release; do
if [ -d "target/$TARGET/$type" ]; then
DIR="target/$TARGET/$type"
break
elif [ -d "target/$type" ]; then
DIR="target/$type"
break
fi
done
if [ -z "$DIR" ]; then
echo "Could not find directory with binary in it under target/"
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"