-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcross-mingw-w64.sh
executable file
·143 lines (103 loc) · 4.45 KB
/
cross-mingw-w64.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
set -e
if [ "$CI" == "" ] && [ -d /dev/shm ]; then
BUILD_DIR=$(mktemp -d -p /dev/shm $TEMP_TEMPLATE)
else
BUILD_DIR=$(mktemp -d $TEMP_TEMPLATE)
fi
cleanup(){
if [ -d "$BUILD_DIR" ]; then
rm -rf "$BUILD_DIR"
fi
}
# Basically RAII for bash
trap cleanup EXIT
REPO_ROOT=$(readlink -f $(dirname $(dirname $0)))
OLD_CWD=$(readlink -f .)
# Switch to build dir
pushd "$BUILD_DIR"
# first make sure OpenSSL is installed
OPENSSL_INSTALL_DIR=$HOME/mingw-w64/openssl
if ! [ -d "$OPENSSL_INSTALL_DIR" ]; then
git clone --depth 1 https://github.com/openssl/openssl.git
pushd openssl
./Configure --cross-compile-prefix=x86_64-w64-mingw32- mingw64
make -j$(nproc)
make install_sw DESTDIR="$HOME/mingw-w64/openssl"
popd
fi
# Now install Qt 5.15
QT_VERSION=5.15
QT_INSTALL_DIR="$HOME/mingw-w64/Qt${QT_VERSION}"
if ! [ -d "$QT_INSTALL_DIR" ]; then
git clone --depth 1 -b ${QT_VERSION} git://code.qt.io/qt/qt5.git
pushd qt5
QT_SUBMODULES="qtbase,qtfeedback,qtimageformats,qtlottie,qtpim,qtqa,qtsvg,qtsystems"
./init-repository --module-subset="$QT_SUBMODULES"
./configure \
-xplatform win32-g++ \
-device-option CROSS_COMPILE=/usr/bin/x86_64-w64-mingw32- \
-prefix "$HOME/mingw-w64/Qt${QT_VERSION}" \
-opensource \
-confirm-license \
-no-compile-examples \
-nomake examples \
-nomake tests \
-nomake tools \
-opengl desktop \
-release \
-skip qtactiveqt -skip qtcharts -skip qtdoc -skip qtlocation \
-skip qtremoteobjects -skip qtserialbus -skip qtserialport -skip qtwebchannel \
-skip qtwebview -skip qtandroidextras -skip qtconnectivity \
-skip qtgamepad -skip qtmacextras -skip qtpurchasing -skip qtscript \
-skip qttranslations -skip qtwebengine -skip qtwinextras \
-skip qtdatavis3d -skip qtgraphicaleffects -skip qtmultimedia \
-skip qtquickcontrols -skip qtscxml -skip qtspeech \
-skip qtvirtualkeyboard -skip qtwebglplugin -skip qtx11extras \
-skip qt3d -skip qtcanvas3d -skip qtdeclarative \
-skip qtnetworkauth -skip qtquickcontrols2 \
-skip qtsensors -skip qtwayland -skip qtwebsockets -skip qtxmlpatterns
make -j$(nproc)
make install
popd
fi
mkdir build-mingw-w64
pushd build-mingw-w64
cmake "$REPO_ROOT" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_TOOLCHAIN_FILE="$REPO_ROOT/toolchains/mingw-w64.cmake" \
-DQt5_DIR="$HOME/mingw-w64/Qt${QT_VERSION}/lib/cmake/Qt5" \
-DQt5Core_DIR="$HOME/mingw-w64/Qt${QT_VERSION}/lib/cmake/Qt5Core" \
-DQt5Network_DIR="$HOME/mingw-w64/Qt${QT_VERSION}/lib/cmake/Qt5Network" \
-DQt5Widgets_DIR="$HOME/mingw-w64/Qt${QT_VERSION}/lib/cmake/Qt5Widgets" \
-DQt5Gui_DIR="$HOME/mingw-w64/Qt${QT_VERSION}/lib/cmake/Qt5Gui" \
-DQt5Svg_DIR="$HOME/mingw-w64/Qt${QT_VERSION}/lib/cmake/Qt5Svg" \
-DQt5Zlib_DIR="$HOME/mingw-w64/Qt${QT_VERSION}/lib/cmake/Qt5Zlib" \
-DQt5ThemeSupport_DIR="$HOME/mingw-w64/Qt${QT_VERSION}/lib/cmake/Qt5ThemeSupport" \
-DQt5AccessibilitySupport_DIR="$HOME/mingw-w64/Qt${QT_VERSION}/lib/cmake/Qt5AccessibilitySupport" \
-DQt5EventDispatcherSupport_DIR="$HOME/mingw-w64/Qt${QT_VERSION}/lib/cmake/Qt5EventDispatcherSupport" \
-DQt5FontDatabaseSupport_DIR="$HOME/mingw-w64/Qt${QT_VERSION}/lib/cmake/Qt5FontDatabaseSupport" \
-DQt5WindowsUIAutomationSupport_DIR="$HOME/mingw-w64/Qt${QT_VERSION}/lib/cmake/Qt5WindowsUIAutomationSupport" \
-DOPENSSL_USE_STATIC_LIBS=TRUE \
-DOPENSSL_ROOT_DIR="$HOME/mingw-w64/openssl/usr/local/" \
-DOPENSSL_INCLUDE_DIR="$HOME/mingw-w64/openssl/usr/local/include/openssl" \
-DOPENSSL_LIBRARIES="$HOME/mingw-w64/openssl/usr/local/lib64" \
-DOPENSSL_CRYPTO_LIBRARY="$HOME/mingw-w64/openssl/usr/local/lib64/libcrypto.a" \
-DOPENSSL_SSL_LIBRARY="$HOME/mingw-w64/openssl/usr/local/lib64/libssl.a"
cmake --build . -- -j$(nproc)
popd
mkdir qide-w64
mv build-mingw-w64/qide/qide.exe qide-w64
cp $QT_INSTALL_DIR/bin/Qt5{Core,Gui,Svg,Widgets,Network}.dll qide-w64
QT_RUNTIME_DIRS=(bearer iconengines imageformats platforms styles)
for runDir in ${QT_RUNTIME_DIRS[@]}; do
mkdir qide-w64/$runDir
cp $QT_INSTALL_DIR/plugins/$runDir/*.dll qide-w64/$runDir
done
GCC_LIBRARIES=(libgcc_s_seh-1.dll libstdc++-6.dll)
for lib in ${GCC_LIBRARIES[@]}; do
cp /usr/lib/gcc/x86_64-w64-mingw32/9.3-posix/$lib qide-w64
done
cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll qide-w64
zip -r qide-w64.zip qide-w64
mv qide-w64.zip $OLD_CWD