-
Notifications
You must be signed in to change notification settings - Fork 59
/
install-dlls-msys2-mingw.sh
78 lines (55 loc) · 2.04 KB
/
install-dlls-msys2-mingw.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/sh
# set -ex
INSTALLDIR=`pwd`/install
if [[ `file $INSTALLDIR/radiant.exe` == *"x86-64"* ]]; then
MINGWDIR=/mingw64
else
MINGWDIR=/mingw32
fi
function dependencies_single_target_no_depth {
local TARGET=$1
local DEPENDENCIESFILTER="| grep -a 'DLL Name' | sed -r 's/\s+DLL\s+Name\:\s+//' | xargs -i{} which {} | grep -a $MINGWDIR/bin"
local COMMAND="objdump -x $TARGET $DEPENDENCIESFILTER | xargs -i{} echo {}"
local DEPENDENCIES=`eval "$COMMAND"`
if [ "$DEPENDENCIES" != "" ]; then
echo "$DEPENDENCIES"
fi
}
function dependencies {
local TARGETS=$@
local TEMPORARYFILEA="install-dlls-msys2-mingw.alldependencies.tmp"
local TEMPORARYFILEB="install-dlls-msys2-mingw.dependencies.tmp"
local ALLDEPENDENCIES=""
for TARGET in $TARGETS; do
local ALLDEPENDENCIES=`dependencies_single_target_no_depth "$TARGET" && echo "$ALLDEPENDENCIES"`
done
local ALLDEPENDENCIES=`echo "$ALLDEPENDENCIES" | sort -u`
local NEWDEPENDENCIES="$ALLDEPENDENCIES"
while [ "$NEWDEPENDENCIES" != "" ]; do
local DEPENDENCIES=""
for DEPENDENCY in $NEWDEPENDENCIES; do
DEPENDENCIES=`dependencies_single_target_no_depth "$DEPENDENCY" && echo "$DEPENDENCIES"`
done
echo "$ALLDEPENDENCIES" > "$TEMPORARYFILEA"
echo "$DEPENDENCIES" | sort -u > "$TEMPORARYFILEB"
local NEWDEPENDENCIES=`comm -13 "$TEMPORARYFILEA" "$TEMPORARYFILEB"`
if [ "$NEWDEPENDENCIES" != "" ]; then
local ALLDEPENDENCIES=`printf '%s\n' "$ALLDEPENDENCIES" "$NEWDEPENDENCIES" | sort`
fi
rm "$TEMPORARYFILEA" "$TEMPORARYFILEB"
done
if [ "$ALLDEPENDENCIES" != "" ]; then
echo "$ALLDEPENDENCIES"
fi
}
for DEPENDENCY in `dependencies ./install/*.exe`; do
cp -v "$DEPENDENCY" "$INSTALLDIR"
done
cd $MINGWDIR
for EXTRAPATH in \
'./share/qt5/plugins/imageformats/*.dll' \
'./share/qt5/plugins/platforms/*.dll' \
'./share/qt5/plugins/styles/*.dll' \
; do
cp --parent -v `find $EXTRAPATH -type f` "$INSTALLDIR"
done