-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmxe.easystrip.sh
executable file
·48 lines (42 loc) · 1.17 KB
/
mxe.easystrip.sh
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
46
47
48
#!/bin/bash
if [ -z "$1" ]; then
echo "No input directory supplied!"
exit 1
fi
if [[ "$1" != *"bin"* ]]; then
echo "No bin folder found in directory!"
exit 1
fi
if [ -z "$2" ]; then
echo "No triplet provided!"
exit 1
fi
if ! [ -x "$(command -v "$2-strip")" ]; then
if ! [ -z "$3" ]; then
if [[ "$3" = "-v" ]]; then
echo "Executable $2-strip not found! LLVM may not be installed yet. Exiting gracefully."
fi
fi
exit 0
fi
echo 'Stripping all DLLs and executables not previously stripped.'
if find "$1" -maxdepth 1 -mindepth 1 -type f -name "*.dll" | grep -q .;
then
for i in $1/*.dll; do
if [ ! -f "$1/stripped-executables/${i#*bin/}" ]; then
$2-strip "$i" -o "$1/stripped-executables/${i#*bin/}"
return_code=$?
echo "$2-strip \"$i\" -o \"$1/stripped-executables/${i#*bin/}\" ran with exit code $return_code"
fi
done
fi
if find "$1" -maxdepth 1 -mindepth 1 -type f -name "*.exe" | grep -q .;
then
for i in $1/*.exe; do
if [ ! -f "$1/stripped-executables/${i#*bin/}" ]; then
$2-strip "$i" -o "$1/stripped-executables/${i#*bin/}"
return_code=$?
echo "$2-strip \"$i\" -o \"$1/stripped-executables/${i#*bin/}\" ran with exit code $return_code"
fi
done
fi