-
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathstrip-binary.sh
More file actions
executable file
·45 lines (39 loc) · 943 Bytes
/
strip-binary.sh
File metadata and controls
executable file
·45 lines (39 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
set -e
set -x
set -o pipefail
TARGET=$1
did_strip=""
strip_binary() {
if [[ $(uname -s) =~ "Darwin" ]]; then
stripped=$(
find "$1" -maxdepth 1 -type f -perm +111 | while read -r exe; do
strip "$exe"
echo "stripped $exe"
done
)
else
stripped=$(
find "$1" -maxdepth 1 -type f -executable | while read -r 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