-
Notifications
You must be signed in to change notification settings - Fork 69
Expand file tree
/
Copy pathDockerfile.win
More file actions
255 lines (244 loc) · 11.4 KB
/
Copy pathDockerfile.win
File metadata and controls
255 lines (244 loc) · 11.4 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
# This file makes it easier to compile the Windows version of XaoS
# in a Docker virtualization in a Linux guest. It creates both a portable ZIP and
# an installer EXE for Windows. Cross-compilation is performed with the Linux
# version of MINGW64. Most dependencies are provided by the MSYS2/MINGW64 packages,
# except for Qt6 (which is compiled twice: first for Linux, then for Linux/MINGW64), and for XaoS.
# Warning: You need about about 79.5 GB of disk space to create the Docker image, and several hours
# of downloading (please use a stable Internet connection) and reasonable compilation time to make everything work.
# How to use this file:
# 1. On Ubuntu Linux, install the package **docker.io**.
# 2. Build the image by entering `sudo docker build .`.
# You will get an image ID at the end of the process.
# 3. Run the image by typing `sudo docker run ID`.
# 4. Run `sudo docker ps -a | head -2` to find out the container identifier CID as output.
# 5. Copy the finished folder with the executable and the required DLLs and extra files,
# plus the created .zip and .exe installer in an arbitrary FOLDER by entering
# `sudo docker cp CID:/build/dist FOLDER`.
# 6. To test the Windows version on Linux, change the working directory to FOLDER,
# find its subdirectory XaoS-VERSION/ and type `wine XaoS.exe` there.
# To test the installer, run `wine xaos-setup.exe` in FOLDER.
# 7. If no longer used, you can remove the Docker container and image by entering
# `sudo docker rm CID` and `sudo docker rmi ID`.
# 1. Get prerequisites and cross compiling tools:
FROM debian:trixie
RUN apt-get update && apt-get install -y \
build-essential cmake git wget zip unzip xz-utils zstd pkg-config \
mingw-w64 mingw-w64-tools g++-mingw-w64-x86-64 \
autoconf automake libtool \
qt6-base-dev qt6-tools-dev qt6-base-dev-tools \
perl python3 ninja-build libdbus-1-dev \
wine
RUN apt-get install -y xvfb
RUN wget -q https://github.com/jrsoftware/issrc/releases/download/is-6_7_3/innosetup-6.7.3.exe -O inno.exe
RUN dpkg --add-architecture i386 && apt-get update && apt-get install -y wine32:i386
RUN xvfb-run wine inno.exe /VERYSILENT /SUPPRESSMSGBOXES /NORESTART
# 2. Create toolchain file for cmake (it will be used to cross-compile XaoS for Windows):
WORKDIR /build
RUN echo "set(CMAKE_SYSTEM_NAME Windows)\n\
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)\n\
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)\n\
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)\n\
set(CMAKE_FIND_ROOT_PATH /opt/mingw64)\n\
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)\n\
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)\n\
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)" \
> /build/toolchain-mingw64.cmake
# 3. Build Qt for Windows via Linux/MINGW64:
## 3/1. Clone repository...
WORKDIR /build
ARG QT6_VERSION=6.10.0
RUN git clone git://code.qt.io/qt/qt5.git qt6
WORKDIR qt6
RUN git switch $QT6_VERSION
RUN perl init-repository
## 3/2. Compile Qt for the Linux host...
WORKDIR ..
RUN mkdir qt6-host-build
WORKDIR qt6-host-build
RUN ../qt6/configure -prefix /opt/qt6-host -opensource -confirm-license -nomake examples -nomake tests
RUN cmake --build . -j$(nproc)
RUN cmake --install .
## 3/3. Cross-compile Qt for Windows...
WORKDIR ..
RUN mkdir qt6-mingw-build
WORKDIR qt6-mingw-build
ARG CC=x86_64-w64-mingw32-gcc \
CXX=x86_64-w64-mingw32-g++ \
AR=x86_64-w64-mingw32-ar \
RANLIB=x86_64-w64-mingw32-ranlib \
STRIP=x86_64-w64-mingw32-strip
RUN ../qt6/configure \
-prefix /opt/qt6-mingw64 -xplatform win32-g++ \
-opensource -confirm-license \
-shared \
-nomake examples -nomake tests \
-skip qtactiveqt -skip qtlanguageserver \
-skip qtquick3d -skip qtmultimedia -skip qtgraphs -skip qtquick3dphysics \
-skip qtquickeffectmaker -skip qtspeech \
-skip qtlottie -skip qtwebview -skip qtwebengine \
-skip qtqmltoolingsettings -skip QtQmlToolingSettingsPrivate \
-qt-host-path /opt/qt6-host \
-cmake-generator Ninja -- \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_SYSROOT=/usr/x86_64-w64-mingw32 \
-DCMAKE_FIND_ROOT_PATH=/usr/x86_64-w64-mingw32 \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM=NEVER \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE=ONLY \
-DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=ONLY
RUN cmake --build . -j$(nproc) -t qtbase -t qttools -t qtsvg -t qtimageformats -t qtdeclarative
RUN cmake --install qtbase
RUN cmake --install . --component tools
RUN cmake --install . --component qml
RUN cmake --install . --component libraries
# 4. Download MSYS2/MINGW64 packages:
WORKDIR /build
ARG MSYS2_MIRROR=https://repo.msys2.org/mingw/mingw64
ARG MSYS2_BROTLI_VERSION=1.2.0-1 \
MSYS2_BZIP2_VERSION=1.0.8-3 \
MSYS2_CAIRO_VERSION=1.18.4-4 \
MSYS2_EXPAT_VERSION=2.7.3-1 \
MSYS2_FONTCONFIG_VERSION=2.17.1-1 \
MSYS2_FREETYPE_VERSION=2.14.1-2 \
MSYS2_FRIBIDI_VERSION=1.0.16-1 \
MSYS2_GDK_PIXBUF2_VERSION=2.44.4-1 \
MSYS2_GETTEXT_VERSION=0.22.4-3 \
MSYS2_GLIB2_VERSION=2.86.3-1 \
MSYS2_GRAPHITE2_VERSION=1.3.14-3 \
MSYS2_HARFBUZZ_VERSION=12.3.0-1 \
MSYS2_JBIGKIT_VERSION=2.1-5 \
MSYS2_PANGO_VERSION=1.56.4-3 \
MSYS2_LERC_VERSION=4.0.0-1 \
MSYS2_LIBDATRIE_VERSION=0.2.14-1 \
MSYS2_LIBDEFLATE_VERSION=1.25-1 \
MSYS2_LIBFFI_VERSION=3.5.2-1 \
MSYS2_LIBICONV_VERSION=1.18-1 \
MSYS2_LIBJPEG_TURBO_VERSION=3.1.3-1 \
MSYS2_LIBLTDL_VERSION=2.5.4-3 \
MSYS2_LIBPNG_VERSION=1.6.53-1 \
MSYS2_LIBRSVG_VERSION=2.61.3-1 \
MSYS2_LIBTHAI_VERSION=0.1.29-3 \
MSYS2_LIBTIFF_VERSION=4.7.1-1 \
MSYS2_LIBWEBP_VERSION=1.6.0-1 \
MSYS2_LIBWINPTHREAD_VERSION=13.0.0.r91.gfc0b67305-1 \
MSYS2_LIBXML2_VERSION=2.15.1-2 \
MSYS2_PCRE2_VERSION=10.47-1 \
MSYS2_PIXMAN_VERSION=0.46.4-1 \
MSYS2_XZ_VERSION=5.8.2-1 \
MSYS2_ZSTD_VERSION=1.5.7-1 \
MSYS2_ZLIB_VERSION=1.3.1-1
ARG DEST=/opt
RUN set | grep ^MSYS2_ | grep _VERSION= | while read SETTING; do \
PACKAGE=`echo $SETTING | cut -d= -f1 | sed s/MSYS2_// | sed s/_VERSION// | tr _ - | awk '{print tolower($0)}'`; \
VERSION=`echo $SETTING | cut -d= -f2 | sed s/"'"//g`; \
FILENAME=mingw-w64-x86_64-$PACKAGE-$VERSION-any.pkg.tar.zst; \
wget -q -N $MSYS2_MIRROR/$FILENAME; \
tar x --zstd -f $FILENAME -C /opt; \
echo $FILENAME; \
done
# 5. Copy sources:
WORKDIR /build/XaoS
COPY . .
# 6/1. Build XaoS:
RUN mkdir build
WORKDIR build
RUN cmake .. -G Ninja \
-DCMAKE_TOOLCHAIN_FILE=/build/toolchain-mingw64.cmake \
-DCMAKE_INSTALL_PREFIX=/opt/mingw64 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="/build/qt6-mingw-build/qtbase/lib/cmake;/opt/mingw64;/opt/mingw64/lib/cmake;/opt/mingw64/lib" \
-DCMAKE_POLICY_DEFAULT_CMP0144=NEW \
-DCMAKE_EXE_LINKER_FLAGS="-L/opt/mingw64/lib"
RUN ninja -j$(nproc)
RUN ninja install || true
# 6/2. Build XaoSMobile:
RUN mkdir ../build2
WORKDIR ../build2
RUN cmake .. -G Ninja \
-DCMAKE_TOOLCHAIN_FILE=/build/toolchain-mingw64.cmake \
-DCMAKE_INSTALL_PREFIX=/opt/mingw64 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="/build/qt6-mingw-build/qtbase/lib/cmake;/opt/mingw64;/opt/mingw64/lib/cmake;/opt/mingw64/lib" \
-DCMAKE_POLICY_DEFAULT_CMP0144=NEW \
-DCMAKE_EXE_LINKER_FLAGS="-L/opt/mingw64/lib" \
-DMOBILE_UI=ON
RUN ninja -j$(nproc)
RUN ninja install || true
# 7. Create Windows folder with all required files:
ARG DIST=/build/dist/XaoS-VERSION
RUN mkdir -p $DIST
# 7/1. Collect MSYS2/MINGW64 DLLs (this may change when versions change)...
ARG MSYS2_MINGW64_DLLS="libbrotlicommon libbrotlidec \
libbrotlienc libbz2-1 libcairo-2 libcairo-gobject-2 \
libcdt-6 libcgraph-8 libdatrie-1 libdeflate \
libexpat-1 libffi-8 libfontconfig-1 libfreetype-6 \
libfribidi-0 libgdk_pixbuf-2.0-0 \
libgio-2.0-0 libglib-2.0-0 libgmodule-2.0-0 \
libgobject-2.0-0 libgraphite2 libgvc-7 \
libgvplugin_core-8 libgvplugin_dot_layout-8 \
libgvplugin_pango-8 libgvplugin_rsvg-8 libharfbuzz-0 \
libiconv-2 libintl-8 libjbig-0 libjpeg-8 libLerc \
libltdl-7 liblzma-5 libpango-1.0-0 libpangocairo-1.0-0 \
libpangoft2-1.0-0 libpangowin32-1.0-0 libpathplan-4 \
libpcre2-8-0 libpixman-1-0 libpng16-16 libwinpthread-1 librsvg-2-2 \
libsharpyuv-0 libthai-0 libtiff-6 \
libwebp-7 libxdot-4 libxml2-16 libzstd"
RUN for i in $MSYS2_MINGW64_DLLS; do \
DLL=`find /opt -name $i.dll | head -1`; \
echo $DLL; \
cp $DLL $DIST; \
done
# 7/2. Collect runtimes from cross compiler...
ARG LINUX_MINGW64_DLLS="libgcc_s_seh-1 libstdc++-6"
RUN for i in $LINUX_MINGW64_DLLS; do \
DLL=`find /usr/lib/gcc/x86_64-w64-mingw32 -name $i.dll | grep win32 | head -1`; \
echo $DLL; \
cp $DLL $DIST; \
done
# 7/3. Collect Qt DLLs (some of them take place in the build folder)...
ARG LINUX_MINGW64_QT6_DLLS="Core DBus Gui \
LabsAnimation LabsFolderListModel LabsPlatform LabsQmlModels LabsSettings LabsSharedImage LabsSynchronizer LabsWavefrontMesh \
Network OpenGL PrintSupport \
Qml QmlCore QmlLocalStorage QmlMeta QmlModels QmlNetwork QmlWorkerScript QmlXmlListModel \
Quick QuickControls2 QuickControls2Basic QuickControls2BasicStyleImpl QuickControls2FluentWinUI3StyleImpl \
QuickControls2Fusion QuickControls2FusionStyleImpl QuickControls2Imagine QuickControls2ImagineStyleImpl \
QuickControls2Impl QuickControls2Material QuickControls2MaterialStyleImpl QuickControls2Universal \
QuickControls2UniversalStyleImpl QuickControls2WindowsStyleImpl QuickDialogs2 QuickDialogs2QuickImpl \
QuickEffects QuickLayouts QuickParticles QuickShapesDesignHelpers QuickShapes QuickTemplates2 \
QuickTest QuickVectorImage QuickVectorImageHelpers QuickWidgets \
Svg SvgWidgets Test Widgets"
RUN for i in $LINUX_MINGW64_QT6_DLLS; do \
DLL=`find /build/qt6-mingw-build -name Qt6$i.dll | head -1`; \
echo $DLL; \
cp $DLL $DIST; \
done
# 7/4. Put the .ico file there...
RUN cp /build/XaoS/src/ui/xaos.ico $DIST
# 7/5. Create additional Qt related settings...
RUN for d in styles platforms imageformats; do \
cp -a /build/qt6-mingw-build/qtbase/plugins/$d $DIST; \
done
RUN cp -a /build/qt6-mingw-build/qtbase/qml $DIST/
# 7/6. Copy executable, catalogs, tutorial, CREDITS, README, NEWS, COPYING...
RUN cp /build/XaoS/build/XaoS.exe $DIST
RUN cp /build/XaoS/build2/XaoSMobile.exe $DIST
RUN mkdir $DIST/catalogs $DIST/tutorial $DIST/examples
RUN cp -a /build/XaoS/catalogs/*.cat $DIST/catalogs
RUN cp -a /build/XaoS/tutorial/*.x?f $DIST/tutorial
RUN find /build/XaoS/examples -name '*.xpf' -exec cp '{}' $DIST/examples \;
RUN cp /build/XaoS/CREDITS.md /build/XaoS/README.md /build/XaoS/NEWS /build/XaoS/COPYING $DIST
# 7/7. Get version number...
RUN cat /build/XaoS/src/include/config.h | grep XaoS_VERSION | awk '{print $3}' | tr -d \" > /build/version
WORKDIR /build/dist
RUN mv XaoS-VERSION XaoS-`cat /build/version`
# 7/8. Create .zip...
WORKDIR /build/dist
RUN VERSION=`cat /build/version` && zip -9r XaoS-$VERSION.zip XaoS-$VERSION
# 8. Create Inno Setup installer:
WORKDIR /build/XaoS
RUN VERSION=`cat /build/version` && ln -s /build/dist/XaoS-`cat /build/version` XaoS-`cat /build/version`
RUN VERSION=`cat /build/version` && cat installer/xaos.iss | sed s/4.3.6/$VERSION/ > /build/dist/xaos-current.iss
RUN cp installer/*.bmp /build/dist
WORKDIR /build/dist
RUN wine "C:\\Program Files (x86)\\Inno Setup 6\\ISCC.exe" xaos-current.iss
RUN mv Output/xaos-setup.exe /build/dist