Skip to content

Commit 787e06b

Browse files
committed
Windows build
1 parent 5f71d08 commit 787e06b

File tree

6 files changed

+164
-60
lines changed

6 files changed

+164
-60
lines changed

CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ project(updater LANGUAGES CXX)
55
set(CMAKE_CXX_STANDARD 17)
66
set(CMAKE_CXX_STANDARD_REQUIRED ON)
77

8+
# triggers in QML generated files
9+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized")
10+
811
# important for quazip
912
set(BUILD_SHARED_LIBS OFF)
1013

@@ -18,6 +21,11 @@ find_package(Qt6 REQUIRED COMPONENTS Core Qml Quick QuickControls2 QuickDialogs2
1821
# Actually only used by Fluid and Quazip, not us. HACK: prevent warning spam
1922
find_package(Qt6 COMPONENTS Core5Compat)
2023

24+
if (WIN32)
25+
set(CMAKE_C_FLAGS "-static -static-libgcc ${CMAKE_C_FLAGS}")
26+
set(CMAKE_CXX_FLAGS "-static -static-libgcc ${CMAKE_CXX_FLAGS}")
27+
endif()
28+
2129
qt_standard_project_setup(REQUIRES 6.8)
2230

2331
option(FLUID_WITH_GALLERY "" OFF)
@@ -28,6 +36,9 @@ add_subdirectory(fluid)
2836
set(QUAZIP_BZIP2 OFF)
2937
set(QUAZIP_ENABLE_TESTS OFF)
3038
set(QUAZIP_FETCH_LIBS OFF)
39+
if (WIN32)
40+
set(QUAZIP_USE_QT_ZLIB ON)
41+
endif()
3142
add_subdirectory(quazip)
3243

3344
set(SOURCES
@@ -61,7 +72,7 @@ else()
6172
list(APPEND SOURCES linux.cpp)
6273
endif()
6374

64-
qt_add_executable(updater
75+
qt_add_executable(updater WIN32
6576
${SOURCES}
6677
qml.qrc
6778
)

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ COPY md5sums-qt.txt build-qt.sh qtbase.patch /build-qt/
7272
ARG release
7373
# Note: {foo:+bar} here is a syntax of the Dockerfile, not the shell!
7474
ENV IPO_ARG=${release:+-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON}
75-
RUN BUILDQT_CMAKE_ARGS="${IPO_ARG} -DCMAKE_POSITION_INDEPENDENT_CODE=OFF -DFEATURE_reduce_relocations=OFF" CXXFLAGS='-fno-pic -no-pie' CFLAGS='-fno-pic -no-pie' PKG_CONFIG_PATH=/openssl/lib64/pkgconfig ./build-qt.sh && mv qt /qt && rm -rf /build-qt
75+
RUN BUILDQT_CMAKE_ARGS="${IPO_ARG} -DCMAKE_POSITION_INDEPENDENT_CODE=OFF -DFEATURE_reduce_relocations=OFF" CXXFLAGS='-fno-pic -no-pie' CFLAGS='-fno-pic -no-pie' PKG_CONFIG_PATH=/openssl/lib64/pkgconfig ./build-qt.sh linux && mv qt_linux /qt && rm -rf /build-qt
7676

7777
###############
7878
# Build aria2 #

Dockerfile.win

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,37 @@ ENV LANG=C.UTF-8
1818
RUN apt-get update && apt-get install -y \
1919
autoconf \
2020
autopoint \
21+
cmake \
2122
curl \
2223
gettext \
2324
g++ \
2425
g++-mingw-w64-i686-posix \
2526
git \
2627
libtool \
2728
make \
29+
ninja-build \
2830
p7zip-full \
2931
pkg-config \
3032
python3 \
3133
xz-utils
3234

33-
# The Schannel dependencies are spelled with capital letters which causes them not to be found
34-
RUN ln -s libsecur32.a /usr/i686-w64-mingw32/lib/libSecur32.a && \
35-
ln -s libcrypt32.a /usr/i686-w64-mingw32/lib/libCrypt32.a
36-
3735
############
3836
# Build Qt #
3937
############
4038
WORKDIR /build-qt
41-
COPY md5sums-qt.txt /build-qt/
42-
ENV UPDATER_MODULES=qtbase,qtquickcontrols,qtquickcontrols2,qtsvg,qtgraphicaleffects
43-
RUN curl -LO https://download.qt.io/archive/qt/5.14/5.14.2/single/qt-everywhere-src-5.14.2.tar.xz && \
44-
md5sum --check --ignore-missing md5sums-qt.txt && \
45-
tar -xJf qt-everywhere-src-5.14.2.tar.xz && \
46-
cd qt-everywhere-src-5.14.2 && \
47-
./configure -release -static -prefix /qt -qt-zlib -qt-libjpeg -qt-libpng -qt-freetype -qt-pcre -qt-harfbuzz -opengl desktop -opensource -confirm-license -no-qml-debug -no-icu -xplatform win32-g++ -device-option CROSS_COMPILE=i686-w64-mingw32- -optimize-size --c++std=14 -nomake tests -nomake tools -nomake examples -schannel -no-feature-d3d12 && \
48-
bash -c "make -j`nproc` module-{$UPDATER_MODULES} && make module-{$UPDATER_MODULES}-install_subtargets" && \
49-
rm -rf /build-qt
39+
40+
# Build host-mode tools and remove everything apart from the installed bin/ and lib/cmake/
41+
COPY md5sums-qt.txt build-qt.sh qtbase.patch cross-toolchain-mingw32.cmake /build-qt/
42+
RUN ./build-qt.sh tools qtbase qtdeclarative qtshadertools && \
43+
rm -r build_tools && \
44+
find qt_tools -mindepth 1 -maxdepth 1 ! -name bin ! -name lib ! -name libexec -exec rm -r {} + && \
45+
find qt_tools/lib -mindepth 1 -maxdepth 1 ! -name cmake -exec rm -r {} +
46+
47+
ARG release
48+
# Note: {foo:+bar} here is a syntax of the Dockerfile, not the shell!
49+
ENV IPO_ARG=${release:+-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON}
50+
RUN BUILDQT_CMAKE_ARGS="${IPO_ARG}"
51+
RUN ./build-qt.sh windows && rm -r build_windows
5052

5153
###############
5254
# Build aria2 #
@@ -64,7 +66,8 @@ RUN CFLAGS=-Os CXXFLAGS=-Os ../build-aria.sh ARIA2_STATIC=yes --host i686-w64-mi
6466
COPY . /updater
6567
RUN set -e; for D in . quazip fluid; do cd /updater/$D && git clean -dXff; done
6668
WORKDIR /build
67-
RUN /qt/bin/qmake -config release QMAKE_LFLAGS+="-static" INCLUDEPATH+=/qt/include/QtZlib /updater && make -j`nproc`
69+
RUN cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=/build-qt/cross-toolchain-mingw32.cmake -DCMAKE_FIND_ROOT_PATH=/build-qt/qt_windows -DCMAKE_BUILD_TYPE=MinSizeRel ${IPO_ARG} /updater && ninja
70+
RUN mv updater.exe updater-nonstripped.exe && i686-w64-mingw32-strip updater-nonstripped.exe -o updater.exe
6871
WORKDIR /release-win
6972
ARG release
70-
RUN if [ -n "$release" ]; then cp /build/release/updater.exe UnvanquishedUpdater.exe && 7z -tzip -mx=9 a UnvUpdaterWin.zip UnvanquishedUpdater.exe; fi
73+
RUN if [ -n "$release" ]; then cp /build/updater.exe UnvanquishedUpdater.exe && 7z -tzip -mx=9 a UnvUpdaterWin.zip UnvanquishedUpdater.exe; fi

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ The first line below runs the Docker build for Windows. The last 3 lines are to
4747
```
4848
docker build -t unvlauncher-win -f Dockerfile.win .
4949
docker create --name unvlauncher-win unvlauncher-win
50-
docker cp unvlauncher-win:/build/release/updater.exe ./build-docker
50+
docker cp unvlauncher-win:/build/updater.exe ./build-docker
5151
docker rm unvlauncher-win
5252
5353
```

build-qt.sh

Lines changed: 119 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

3-
# Usage: [EXTRA_CMAKE_ARGS=<args...>] build-qt.sh [<qt submodule>...]
4-
# installs to ./qt/
3+
# Usage: [EXTRA_CMAKE_ARGS=<args...>] build-qt.sh <sysname> [<qt submodule>...]
4+
# installs to ./qt_<sysname>/
55

66
set -e
77
set -u
@@ -16,7 +16,7 @@ prefix_output() {
1616
module_vars() {
1717
url="https://download.qt.io/archive/qt/6.8/6.8.3/submodules/${1}-everywhere-src-6.8.3.tar.xz"
1818
archive="${url##*/}"
19-
dirname="${archive%.tar.*}"
19+
dirname="build_${sysname}/${archive%.tar.*}"
2020
}
2121

2222

@@ -35,9 +35,12 @@ build_module() {
3535
cmake --install .
3636
}
3737

38+
sysname="${1}"
39+
shift
40+
3841
WORK_DIR="${PWD}"
3942
SCRIPT_DIR=$(realpath "$(dirname "$0")")
40-
INSTALL_DIR="${WORK_DIR}/qt"
43+
INSTALL_DIR="${WORK_DIR}/qt_${sysname}"
4144

4245
#FIXME bad warning in qtdeclarative-everywhere-src-6.8.3/src/quickwidgets/qquickwidget.cpp
4346

@@ -46,38 +49,8 @@ common_options_cmake="
4649
-DQT_GENERATE_SBOM=OFF
4750
${BUILDQT_CMAKE_ARGS:-}
4851
"
49-
options_qtbase="
50-
-opensource
51-
-confirm-license
52-
-release
53-
-optimize-size
54-
-no-shared
55-
-static
56-
--c++std=17
57-
-disable-deprecated-up-to 0x060800
58-
-reduce-exports
59-
-gc-binaries
60-
-qpa xcb
61-
-nomake tests
62-
-nomake examples
63-
-no-gif
64-
-no-icu
65-
-no-glib
66-
-opengl desktop
67-
-no-eglfs
68-
-no-opengles3
69-
-no-egl
70-
-xkbcommon
71-
-dbus-runtime
72-
-qt-freetype
73-
-qt-pcre
74-
-qt-harfbuzz
75-
-qt-libpng
76-
-qt-libjpeg
77-
-system-zlib
78-
-openssl-linked
79-
-prefix ${INSTALL_DIR}
80-
--
52+
53+
base_features='
8154
-DFEATURE_androiddeployqt=OFF
8255
-DFEATURE_animation=ON
8356
-DFEATURE_cborstreamwriter=OFF
@@ -139,7 +112,6 @@ options_qtbase="
139112
-DFEATURE_mimetype_database=OFF
140113
-DFEATURE_movie=OFF
141114
-DFEATURE_networkdiskcache=OFF
142-
-DFEATURE_opengl_desktop=ON
143115
-DFEATURE_pdf=OFF
144116
-DFEATURE_picture=OFF
145117
-DFEATURE_printsupport=OFF
@@ -171,6 +143,9 @@ options_qtbase="
171143
-DFEATURE_stringlistmodel=OFF
172144
-DFEATURE_style_fusion=OFF
173145
-DFEATURE_style_stylesheet=OFF
146+
-DFEATURE_style_windows=ON
147+
-DFEATURE_style_windows11=OFF
148+
-DFEATURE_style_windowsvista=OFF
174149
-DFEATURE_syntaxhighlighter=OFF
175150
-DFEATURE_systemtrayicon=OFF
176151
-DFEATURE_tabbar=OFF
@@ -205,10 +180,39 @@ options_qtbase="
205180
-DFEATURE_whatsthis=OFF
206181
-DFEATURE_widgettextcontrol=ON
207182
-DFEATURE_wizard=OFF
208-
-DFEATURE_xcb=ON
209-
-DFEATURE_xcb_glx_plugin=ON
210183
-DFEATURE_xml=OFF
211184
-DFEATURE_xmlstream=ON
185+
'
186+
187+
options_qtbase="
188+
-opensource
189+
-confirm-license
190+
-release
191+
-optimize-size
192+
-no-shared
193+
-static
194+
--c++std=17
195+
-disable-deprecated-up-to 0x060800
196+
-reduce-exports
197+
-gc-binaries
198+
-nomake tests
199+
-nomake examples
200+
-no-gif
201+
-no-icu
202+
-no-glib
203+
-opengl desktop
204+
-no-eglfs
205+
-no-opengles3
206+
-no-egl
207+
-qt-freetype
208+
-qt-pcre
209+
-qt-harfbuzz
210+
-qt-libpng
211+
-qt-libjpeg
212+
-prefix ${INSTALL_DIR}
213+
--
214+
${base_features}
215+
-DFEATURE_opengl_desktop=ON
212216
-DQT_BUILD_DOCS=OFF
213217
"
214218
options_qt5compat='--'
@@ -239,9 +243,80 @@ options_qtdeclarative='
239243
-DFEATURE_quicktemplates2_multitouch=OFF
240244
'
241245

246+
case "${sysname}" in
247+
linux)
248+
options_qtbase="
249+
-dbus-runtime
250+
-openssl-linked
251+
-qpa xcb
252+
-system-zlib
253+
-xkbcommon
254+
${options_qtbase}
255+
-DFEATURE_xcb=ON
256+
-DFEATURE_xcb_glx_plugin=ON
257+
"
258+
;;
259+
macos)
260+
;;
261+
windows)
262+
options_qtbase="
263+
-device-option CROSS_COMPILE=i686-w64-mingw32-
264+
-xplatform win32-g++
265+
-schannel
266+
${options_qtbase}
267+
-DFEATURE_imageformat_xpm=ON
268+
-DFEATURE_library=ON
269+
-DCMAKE_TOOLCHAIN_FILE=${SCRIPT_DIR}/cross-toolchain-mingw32.cmake
270+
-DQT_HOST_PATH=${WORK_DIR}/qt_tools
271+
"
272+
# -no-feature-d3d12
273+
274+
;;
275+
tools)
276+
options_qtbase="
277+
--c++std=17
278+
-release
279+
-static
280+
-qpa none
281+
-no-opengl
282+
-no-harfbuzz
283+
-no-freetype
284+
-no-ico
285+
-no-gif
286+
-no-xkbcommon
287+
-no-openssl
288+
-prefix ${INSTALL_DIR}
289+
--
290+
${base_features}
291+
-DFEATURE_widgets=OFF
292+
-DFEATURE_network=OFF
293+
-DFEATURE_harfbuzz=OFF
294+
-DFEATURE_evdev=OFF
295+
-DFEATURE_cursor=OFF
296+
-DFEATURE_linuxfb=OFF
297+
-DFEATURE_freetype=OFF
298+
-DxxxFEATURE_pcre2=OFF
299+
-DFEATURE_libinput=OFF
300+
-DFEATURE_imageformat_jpeg=OFF
301+
-DFEATURE_imageformat_png=OFF
302+
-DFEATURE_imageformatplugin=OFF
303+
"
304+
options_qtdeclarative='
305+
--
306+
'
307+
;;
308+
*)
309+
echo 'arg 1 should be linux|macos|windows'
310+
exit 1
311+
esac
312+
242313
# qt5compat depends on qtdeclarative
243-
# qtdeclarative depends on qtshadertools, qtsvg
244-
MODULES=${@:-qtbase qtsvg qtshadertools qtdeclarative qt5compat}
314+
# qtdeclarative depends on qtshadertools
315+
# qtdeclarative optionally depends on qtsvg but we don't actually want that?
316+
# Also in the tools build we strategically build qtdeclarative before qtshadertools to disable
317+
# the bulk of QML targets (TODO: disable them explicitly with options?)
318+
319+
MODULES=${@:-qtbase qtshadertools qtdeclarative qt5compat qtsvg}
245320

246321
# for bloaty
247322
# options_qtbase="-force-debug-info ${options_qtbase}"
@@ -260,11 +335,13 @@ wait
260335

261336
md5sum --check --ignore-missing "${SCRIPT_DIR}/md5sums-qt.txt"
262337

338+
mkdir -p "${WORK_DIR}/build_${sysname}"
339+
263340
# Nuke old dir; extract in parallel
264341
for module in $MODULES; do
265342
module_vars "${module}"
266343
rm -rf "${dirname}"
267-
tar -xJf "${archive}" &
344+
tar -C "${WORK_DIR}/build_${sysname}" -xJf "${archive}" &
268345
done
269346
wait
270347

qtbase.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ diff -u -r qtbase.old/cmake/QtBuildHelpers.cmake qtbase.new/cmake/QtBuildHelpers
2121
qt_internal_set_link_depends_no_shared()
2222
qt_internal_setup_default_install_prefix()
2323
qt_internal_set_qt_source_tree_var()
24+
diff -u -r qtbase.old/src/plugins/platforms/windows/qwindowsmenu.h qtbase.new/src/plugins/platforms/windows/qwindowsmenu.h
25+
--- qtbase.old/src/plugins/platforms/windows/qwindowsmenu.h 2025-02-13 11:45:28.000000000 -0600
26+
+++ qtbase.new/src/plugins/platforms/windows/qwindowsmenu.h 2025-11-17 03:52:17.033997423 -0600
27+
@@ -76,7 +76,9 @@
28+
bool m_checkable = false;
29+
bool m_checked = false;
30+
bool m_enabled = true;
31+
+#ifndef QT_NO_SHORTCUT
32+
QKeySequence m_shortcut;
33+
+#endif
34+
};
35+
36+
class QWindowsMenu : public QPlatformMenu
2437
diff -u -r qtbase.old/src/tools/rcc/rcc.cpp qtbase.new/src/tools/rcc/rcc.cpp
2538
--- qtbase.old/src/tools/rcc/rcc.cpp 2025-02-13 11:45:28.000000000 -0600
2639
+++ qtbase.new/src/tools/rcc/rcc.cpp 2025-11-14 00:12:48.076214506 -0600

0 commit comments

Comments
 (0)