ci: add Windows on ARM64 cross-compilation and packaging jobs

- Add `build-windows-arm64` and `package-windows-arm64` stages to `.gitlab-ci.yml` and wire download links to wiki updates
- Create `scripts/mingw-w64-arm64-toolchain.cmake` targeting `Windows` / `aarch64` with LLVM-MinGW
- Update `docker/Dockerfile.build` with LLVM-MinGW toolchain, MSYS2 Qt 6.10 ARM64 packages, and ARM64 cross-compiled static libraries (libiconv, uchardet, zlib, minizip, libarchive)
- Isolate GCC x86_64 and LLVM-MinGW ARM64 toolchains in `scripts/mingw-w64-toolchain.cmake` and PATH configuration
- Refactor `packaging/package-windows.sh` to package both x86_64 and ARM64 runtime DLLs and support MSYS2 plugin/QML directory layouts
- Update `scripts/test-ci-windows.sh` with `--arm64`, `--only-arm64`, `--image`, and local image detection
- Guard `-mwindows` link flag with `if(MINGW)` in `CMakeLists.txt`
- Document Windows ARM64 build targets and instructions in `AGENTS.md` and `README.md`
This commit is contained in:
Agel committed 2026-10-31 14:15:36 +01:00
1 parent ab4da4696f
commit 8782a3be8a
9 files changed
+337 -72

No files matched your search

+56 -5
View File
@@ -11,6 +11,8 @@ workflow:
- changes:
- docker/Dockerfile.build
- scripts/install-deps-ubuntu.sh
- scripts/mingw-w64-toolchain.cmake
- scripts/mingw-w64-arm64-toolchain.cmake
variables:
CI_PIPELINE_TYPE: image-rebuild
- variables:
@@ -73,7 +75,7 @@ build-linux:
when: never
- when: on_success
# ── Windows cross-compile build (MinGW-w64) ───────────────────────────────────
# ── Windows cross-compile build (MinGW-w64 x86_64) ───────────────────────────
build-windows:
interruptible: true
tags:
@@ -98,6 +100,31 @@ build-windows:
when: never
- when: on_success
# ── Windows cross-compile build (LLVM-MinGW ARM64) ────────────────────────────
build-windows-arm64:
interruptible: true
tags:
- linux-qt
stage: build
script:
- PKG_CONFIG_PATH="${MINGW_ARM64_SYSROOT}/lib/pkgconfig" cmake -B build-windows-arm64 -G Ninja
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_TOOLCHAIN_FILE="${CI_PROJECT_DIR}/scripts/mingw-w64-arm64-toolchain.cmake"
-DCMAKE_PREFIX_PATH="${QT_WINDOWS_ARM64_DIR};${MINGW_ARM64_SYSROOT}"
-DCMAKE_FIND_ROOT_PATH="${QT_WINDOWS_ARM64_DIR};${MINGW_ARM64_SYSROOT}"
-DQT_HOST_PATH="${QT_LINUX_DIR}"
- cmake --build build-windows-arm64 --target asteria-qt
artifacts:
name: "asteria-qt-windows-arm64-${CI_COMMIT_SHORT_SHA}"
paths:
- build-windows-arm64/asteria-qt.exe
expire_in: 1 day
when: on_success
rules:
- if: $CI_PIPELINE_TYPE == "image-rebuild"
when: never
- when: on_success
# ── Linux tests ────────────────────────────────────────────────────────────────
test-linux:
interruptible: true
@@ -137,7 +164,7 @@ package-linux:
when: never
- when: on_success
# ── Package Windows as portable zip ──────────────────────────────────────────
# ── Package Windows x86_64 as portable zip ───────────────────────────────────
package-windows:
interruptible: true
tags:
@@ -147,7 +174,7 @@ package-windows:
- build-windows
script:
- chmod +x packaging/package-windows.sh
- packaging/package-windows.sh build-windows "${QT_WINDOWS_DIR}" "${MINGW_SYSROOT}" .
- packaging/package-windows.sh build-windows "${QT_WINDOWS_DIR}" "${MINGW_SYSROOT}" . x86_64
artifacts:
name: "asteria-qt-windows-${CI_COMMIT_SHORT_SHA}"
paths:
@@ -159,6 +186,28 @@ package-windows:
when: never
- when: on_success
# ── Package Windows ARM64 as portable zip ─────────────────────────────────────
package-windows-arm64:
interruptible: true
tags:
- linux-qt
stage: package
needs:
- build-windows-arm64
script:
- chmod +x packaging/package-windows.sh
- packaging/package-windows.sh build-windows-arm64 "${QT_WINDOWS_ARM64_DIR}" "${MINGW_ARM64_SYSROOT}" . arm64
artifacts:
name: "asteria-qt-windows-arm64-${CI_COMMIT_SHORT_SHA}"
paths:
- asteria-qt-windows-arm64/
expire_in: 1 day
when: on_success
rules:
- if: $CI_PIPELINE_TYPE == "image-rebuild"
when: never
- when: on_success
# ── Update wiki with latest dev build links ────────────────────────────────────
update-wiki:
stage: wiki
@@ -167,6 +216,7 @@ update-wiki:
needs:
- package-linux
- package-windows
- package-windows-arm64
script:
- |
if [ -z "${GITLAB_TOKEN}" ]; then
@@ -179,14 +229,15 @@ update-wiki:
- ARTIFACTS_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/download"
- LINUX_URL="${ARTIFACTS_URL}?job=package-linux"
- WINDOWS_URL="${ARTIFACTS_URL}?job=package-windows"
- WINDOWS_ARM64_URL="${ARTIFACTS_URL}?job=package-windows-arm64"
- |
HTTP_CODE=$(curl -s -o /tmp/wiki.json -w '%{http_code}' \
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
"${WIKI_URL}")
NEW_SECTION=$(printf '## Latest dev builds\n\n> Updated automatically by pipeline [#%s](%s) from `%s` @ %s\n\n| Platform | Download |\n|----------|----------|\n| Linux (x86_64) | [AppImage](%s) |\n| Windows (x86_64) | [Portable zip](%s) |' \
NEW_SECTION=$(printf '## Latest dev builds\n\n> Updated automatically by pipeline [#%s](%s) from `%s` @ %s\n\n| Platform | Download |\n|----------|----------|\n| Linux (x86_64) | [AppImage](%s) |\n| Windows (x86_64) | [Portable zip](%s) |\n| Windows (ARM64) | [Portable zip](%s) |' \
"${CI_PIPELINE_ID}" "${CI_PIPELINE_URL}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_SHORT_SHA}" \
"${LINUX_URL}" "${WINDOWS_URL}")
"${LINUX_URL}" "${WINDOWS_URL}" "${WINDOWS_ARM64_URL}")
if [ "${HTTP_CODE}" = "200" ]; then
WIKI_CONTENT=$(jq -r '.content' /tmp/wiki.json)
+17 -1
View File
@@ -54,7 +54,7 @@ Full target format list:
- Qt 6.10+ components: `Core`, `Gui`, `Qml`, `Quick`, `Widgets`, `Concurrent`, `Svg`, `QuickControls2`, `Test`, `Xml`, `Network`, optional `DBus`.
- Third-party packages: `minizip`, `libarchive`, `iconv`, optional `uchardet`.
### Windows Build Environment
### Windows Build Environment (x86_64)
Qt 6.10.3 at `C:\msys64\opt\qt\6.10.3\mingw_64`. MinGW toolchain at `C:\msys64\mingw64\bin\`:
```bash
PATH="/c/msys64/mingw64/bin:$PATH" "C:/msys64/mingw64/bin/cmake.exe" \
@@ -69,6 +69,22 @@ PATH="/c/msys64/mingw64/bin:$PATH" "C:/msys64/mingw64/bin/ninja.exe" -C build
PATH="/c/msys64/opt/qt/6.10.3/mingw_64/bin:/c/msys64/mingw64/bin:$PATH" "C:/msys64/mingw64/bin/ctest.exe" --test-dir build --output-on-failure
```
### Windows ARM64 Cross-Compilation Environment (Linux host / CI)
Cross-compiled using `llvm-mingw` (`aarch64-w64-mingw32`) and MSYS2 `clangarm64` Qt 6 / sysroot packages:
```bash
PKG_CONFIG_PATH="/opt/mingw-arm64-sysroot/lib/pkgconfig" cmake -B build-windows-arm64 -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=scripts/mingw-w64-arm64-toolchain.cmake \
-DCMAKE_PREFIX_PATH="/opt/qt/6.10.3/mingw_arm64;/opt/mingw-arm64-sysroot" \
-DCMAKE_FIND_ROOT_PATH="/opt/qt/6.10.3/mingw_arm64;/opt/mingw-arm64-sysroot" \
-DQT_HOST_PATH="/opt/qt/6.10.3/gcc_64"
cmake --build build-windows-arm64 --target asteria-qt
```
Packaging:
```bash
packaging/package-windows.sh build-windows-arm64 /opt/qt/6.10.3/mingw_arm64 /opt/mingw-arm64-sysroot dist arm64
```
### Linux Build Environment (Ubuntu 24.04)
```bash
cmake -S . -B build -G Ninja \
+1 -1
View File
@@ -130,7 +130,7 @@ set_target_properties(asteria-qt PROPERTIES
WIN32_EXECUTABLE $<NOT:$<CONFIG:Debug>>
)
if(WIN32)
if(MINGW)
target_link_options(asteria-qt PRIVATE
$<$<NOT:$<CONFIG:Debug>>:-mwindows>)
endif()
+1 -1
View File
@@ -3,7 +3,7 @@
A cross-platform desktop book/document reader built with Qt6/C++.
Reimplementation of [asteria-bookreader](../asteria-bookreader) (Electron/React) using a native Qt stack.
**Target platforms:** Windows and Linux; macOS planned.
**Target platforms:** Windows (x86_64 and ARM64), Linux, and macOS.
## Prerequisites
+120 -19
View File
@@ -3,6 +3,8 @@ FROM ubuntu:24.04
ARG QT_VERSION=6.10.3
ARG QT_INSTALL_DIR=/opt/qt
ARG ZLIB_VERSION=1.3.1
ARG LLVM_MINGW_VERSION=20240917
ARG LIBARCHIVE_VERSION=3.8.0
ENV DEBIAN_FRONTEND=noninteractive
ENV QT_VERSION=${QT_VERSION}
@@ -20,6 +22,7 @@ RUN apt-get update -qq && \
libdjvulibre-dev libwpd-dev \
libxcb-cursor0 \
libtiff6 \
zstd xz-utils wget curl jq zip patchelf file \
&& rm -rf /var/lib/apt/lists/* && \
ln -s /usr/lib/x86_64-linux-gnu/libtiff.so.6 /usr/lib/x86_64-linux-gnu/libtiff.so.5
@@ -31,26 +34,65 @@ RUN aqt install-qt linux desktop ${QT_VERSION} linux_gcc_64 \
-m qtimageformats qtpdf qtwebview \
--outputdir ${QT_INSTALL_DIR}
# ── Qt 6 for Windows (MinGW cross-compile target) ─────────────────────────────
# ── Qt 6 for Windows x86_64 (MinGW cross-compile target) ──────────────────────
RUN aqt install-qt windows desktop ${QT_VERSION} win64_mingw \
-m qtimageformats qtpdf qtwebview \
--outputdir ${QT_INSTALL_DIR}
# ── libiconv for MinGW (static, cross-compiled) ───────────────────────────────
# ── llvm-mingw for Windows ARM64 (aarch64-w64-mingw32) ────────────────────────
RUN wget -q https://github.com/mstorsjo/llvm-mingw/releases/download/${LLVM_MINGW_VERSION}/llvm-mingw-${LLVM_MINGW_VERSION}-ucrt-ubuntu-20.04-x86_64.tar.xz \
-O /tmp/llvm-mingw.tar.xz && \
tar -xf /tmp/llvm-mingw.tar.xz -C /opt && \
mv /opt/llvm-mingw-${LLVM_MINGW_VERSION}-ucrt-ubuntu-20.04-x86_64 /opt/llvm-mingw && \
rm /tmp/llvm-mingw.tar.xz
ENV PATH="${PATH}:/opt/llvm-mingw/bin"
# ── Qt 6 for Windows ARM64 (MinGW cross-compile target) ────────────────────────
RUN mkdir -p ${QT_INSTALL_DIR}/${QT_VERSION}/mingw_arm64 && \
for pkg in \
mingw-w64-clang-aarch64-qt6-base \
mingw-w64-clang-aarch64-qt6-declarative \
mingw-w64-clang-aarch64-qt6-svg \
mingw-w64-clang-aarch64-qt6-5compat \
mingw-w64-clang-aarch64-pcre2 \
mingw-w64-clang-aarch64-double-conversion \
mingw-w64-clang-aarch64-zstd \
mingw-w64-clang-aarch64-brotli \
mingw-w64-clang-aarch64-harfbuzz \
mingw-w64-clang-aarch64-freetype \
mingw-w64-clang-aarch64-libpng; do \
file=$(curl -sL https://mirror.msys2.org/mingw/clangarm64/ | grep -o "${pkg}-[0-9][^\"]*pkg\.tar\.zst" | head -n 1) && \
wget -q "https://mirror.msys2.org/mingw/clangarm64/${file}" -O /tmp/pkg.tar.zst && \
tar -I zstd -xf /tmp/pkg.tar.zst --strip-components=1 -C "${QT_INSTALL_DIR}/${QT_VERSION}/mingw_arm64" && \
rm /tmp/pkg.tar.zst; \
done
# ── Toolchain files ────────────────────────────────────────────────────────────
COPY scripts/mingw-w64-toolchain.cmake /opt/mingw-w64-toolchain.cmake
COPY scripts/mingw-w64-arm64-toolchain.cmake /opt/mingw-w64-arm64-toolchain.cmake
RUN apt-get update -qq && apt-get install -y --no-install-recommends wget && rm -rf /var/lib/apt/lists/*
# ── libiconv for MinGW (static, cross-compiled x86_64 & arm64) ────────────────
RUN wget -q https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.17.tar.gz -O /tmp/libiconv.tar.gz && \
tar -xf /tmp/libiconv.tar.gz -C /tmp && \
\
# x86_64
cd /tmp/libiconv-1.17 && \
./configure --host=x86_64-w64-mingw32 --prefix=/opt/mingw-sysroot \
--enable-static --disable-shared --disable-nls && \
make -j$(nproc) && make install && make clean && \
\
# arm64
./configure --host=aarch64-w64-mingw32 --prefix=/opt/mingw-arm64-sysroot \
--enable-static --disable-shared --disable-nls && \
make -j$(nproc) && make install && \
\
rm -rf /tmp/libiconv-1.17 /tmp/libiconv.tar.gz
# ── uchardet for MinGW (static, cross-compiled) ───────────────────────────────
# ── uchardet for MinGW (static, cross-compiled x86_64 & arm64) ────────────────
RUN git clone --depth 1 https://gitlab.freedesktop.org/uchardet/uchardet.git /tmp/uchardet && \
\
# x86_64
cmake -B /tmp/uchardet-build /tmp/uchardet -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/opt/mingw-w64-toolchain.cmake \
@@ -58,13 +100,23 @@ RUN git clone --depth 1 https://gitlab.freedesktop.org/uchardet/uchardet.git /tm
-DBUILD_SHARED_LIBS=OFF && \
cmake --build /tmp/uchardet-build && \
cmake --install /tmp/uchardet-build && \
rm -rf /tmp/uchardet /tmp/uchardet-build
\
# arm64
cmake -B /tmp/uchardet-arm64-build /tmp/uchardet -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/opt/mingw-w64-arm64-toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=/opt/mingw-arm64-sysroot \
-DBUILD_SHARED_LIBS=OFF && \
cmake --build /tmp/uchardet-arm64-build && \
cmake --install /tmp/uchardet-arm64-build && \
\
rm -rf /tmp/uchardet /tmp/uchardet-build /tmp/uchardet-arm64-build
# ── zlib + minizip for MinGW (static, cross-compiled) ─────────────────────────
# ── zlib + minizip for MinGW (static, cross-compiled x86_64 & arm64) ──────────
RUN wget -q https://github.com/madler/zlib/archive/refs/tags/v${ZLIB_VERSION}.tar.gz -O /tmp/zlib.tar.gz && \
tar -xf /tmp/zlib.tar.gz -C /tmp && \
\
# Build zlib static lib using the MinGW-specific Makefile
# x86_64 zlib
cd /tmp/zlib-${ZLIB_VERSION} && \
make -f win32/Makefile.gcc \
PREFIX=x86_64-w64-mingw32- \
@@ -73,7 +125,7 @@ RUN wget -q https://github.com/madler/zlib/archive/refs/tags/v${ZLIB_VERSION}.ta
LIBRARY_PATH=/opt/mingw-sysroot/lib \
SHARED_MODE=0 install && \
\
# Build minizip static lib from contrib/minizip
# x86_64 minizip
cd /tmp/zlib-${ZLIB_VERSION}/contrib/minizip && \
x86_64-w64-mingw32-gcc -c \
-I/opt/mingw-sysroot/include \
@@ -83,18 +135,42 @@ RUN wget -q https://github.com/madler/zlib/archive/refs/tags/v${ZLIB_VERSION}.ta
cp libminizip.a /opt/mingw-sysroot/lib/ && \
mkdir -p /opt/mingw-sysroot/include/minizip && \
cp ioapi.h unzip.h zip.h /opt/mingw-sysroot/include/minizip/ && \
\
# Write pkg-config file
mkdir -p /opt/mingw-sysroot/lib/pkgconfig && \
printf 'prefix=/opt/mingw-sysroot\nlibdir=${prefix}/lib\nincludedir=${prefix}/include/minizip\n\nName: minizip\nDescription: Minizip zip/unzip library\nVersion: %s\nLibs: -L${libdir} -lminizip -lz\nCflags: -I${includedir}\n' "${ZLIB_VERSION}" \
> /opt/mingw-sysroot/lib/pkgconfig/minizip.pc && \
\
# arm64 zlib
cd /tmp/zlib-${ZLIB_VERSION} && \
make -f win32/Makefile.gcc clean && \
make -f win32/Makefile.gcc \
PREFIX=aarch64-w64-mingw32- \
BINARY_PATH=/opt/mingw-arm64-sysroot/bin \
INCLUDE_PATH=/opt/mingw-arm64-sysroot/include \
LIBRARY_PATH=/opt/mingw-arm64-sysroot/lib \
SHARED_MODE=0 install && \
\
# arm64 minizip
cd /tmp/zlib-${ZLIB_VERSION}/contrib/minizip && \
rm -f *.o libminizip.a && \
aarch64-w64-mingw32-gcc -c \
-I/opt/mingw-arm64-sysroot/include \
-DNOUNCRYPT -DNOCRYPT \
ioapi.c unzip.c zip.c && \
aarch64-w64-mingw32-ar rcs libminizip.a ioapi.o unzip.o zip.o && \
cp libminizip.a /opt/mingw-arm64-sysroot/lib/ && \
mkdir -p /opt/mingw-arm64-sysroot/include/minizip && \
cp ioapi.h unzip.h zip.h /opt/mingw-arm64-sysroot/include/minizip/ && \
mkdir -p /opt/mingw-arm64-sysroot/lib/pkgconfig && \
printf 'prefix=/opt/mingw-arm64-sysroot\nlibdir=${prefix}/lib\nincludedir=${prefix}/include/minizip\n\nName: minizip\nDescription: Minizip zip/unzip library\nVersion: %s\nLibs: -L${libdir} -lminizip -lz\nCflags: -I${includedir}\n' "${ZLIB_VERSION}" \
> /opt/mingw-arm64-sysroot/lib/pkgconfig/minizip.pc && \
\
rm -rf /tmp/zlib-${ZLIB_VERSION} /tmp/zlib.tar.gz
# ── libarchive for MinGW (static, cross-compiled) ─────────────────────────────
ARG LIBARCHIVE_VERSION=3.8.0
# ── libarchive for MinGW (static, cross-compiled x86_64 & arm64) ──────────────
RUN wget -q https://github.com/libarchive/libarchive/releases/download/v${LIBARCHIVE_VERSION}/libarchive-${LIBARCHIVE_VERSION}.tar.gz -O /tmp/libarchive.tar.gz && \
tar -xf /tmp/libarchive.tar.gz -C /tmp && \
\
# x86_64
cmake -B /tmp/libarchive-build /tmp/libarchive-${LIBARCHIVE_VERSION} -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/opt/mingw-w64-toolchain.cmake \
@@ -116,11 +192,37 @@ RUN wget -q https://github.com/libarchive/libarchive/releases/download/v${LIBARC
-DZLIB_LIBRARY=/opt/mingw-sysroot/lib/libz.a && \
cmake --build /tmp/libarchive-build && \
cmake --install /tmp/libarchive-build && \
rm -rf /tmp/libarchive-${LIBARCHIVE_VERSION} /tmp/libarchive.tar.gz /tmp/libarchive-build
\
# arm64
cmake -B /tmp/libarchive-arm64-build /tmp/libarchive-${LIBARCHIVE_VERSION} -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/opt/mingw-w64-arm64-toolchain.cmake \
-DCMAKE_INSTALL_PREFIX=/opt/mingw-arm64-sysroot \
-DBUILD_SHARED_LIBS=OFF \
-DENABLE_TEST=OFF \
-DENABLE_TAR=OFF \
-DENABLE_CPIO=OFF \
-DENABLE_CAT=OFF \
-DENABLE_UNZIP=OFF \
-DENABLE_OPENSSL=OFF \
-DENABLE_LIBB2=OFF \
-DENABLE_LZ4=OFF \
-DENABLE_LZO=OFF \
-DENABLE_MBEDTLS=OFF \
-DENABLE_NETTLE=OFF \
-DENABLE_CNG=OFF \
-DZLIB_INCLUDE_DIR=/opt/mingw-arm64-sysroot/include \
-DZLIB_LIBRARY=/opt/mingw-arm64-sysroot/lib/libz.a && \
cmake --build /tmp/libarchive-arm64-build && \
cmake --install /tmp/libarchive-arm64-build && \
\
rm -rf /tmp/libarchive-${LIBARCHIVE_VERSION} /tmp/libarchive.tar.gz /tmp/libarchive-build /tmp/libarchive-arm64-build
ENV QT_LINUX_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64
ENV QT_WINDOWS_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/mingw_64
ENV QT_WINDOWS_ARM64_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/mingw_arm64
ENV MINGW_SYSROOT=/opt/mingw-sysroot
ENV MINGW_ARM64_SYSROOT=/opt/mingw-arm64-sysroot
# ── linuxdeploy + Qt plugin (for AppImage packaging) ────────────────────────
RUN wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage \
@@ -131,10 +233,13 @@ RUN wget -q https://github.com/linuxdeploy/linuxdeploy/releases/download/continu
chmod +x /usr/local/bin/linuxdeploy-plugin-qt
# ── FUSE not available in Docker — extract AppImage tools ────────────────────
# Note: Zeroing AppImage magic bytes 8-10 allows execution under both native Linux and Rosetta 2 emulation
RUN cd /tmp && \
printf '\000\000\000' | dd of=/usr/local/bin/linuxdeploy bs=1 seek=8 count=3 conv=notrunc && \
/usr/local/bin/linuxdeploy --appimage-extract && \
mv squashfs-root /opt/linuxdeploy && \
ln -sf /opt/linuxdeploy/AppRun /usr/local/bin/linuxdeploy && \
printf '\000\000\000' | dd of=/usr/local/bin/linuxdeploy-plugin-qt bs=1 seek=8 count=3 conv=notrunc && \
/usr/local/bin/linuxdeploy-plugin-qt --appimage-extract && \
mv squashfs-root /opt/linuxdeploy-plugin-qt && \
ln -sf /opt/linuxdeploy-plugin-qt/AppRun /usr/local/bin/linuxdeploy-plugin-qt
@@ -143,16 +248,12 @@ RUN cd /tmp && \
RUN wget -q https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage \
-O /tmp/appimagetool && \
chmod +x /tmp/appimagetool && \
printf '\000\000\000' | dd of=/tmp/appimagetool bs=1 seek=8 count=3 conv=notrunc && \
cd /tmp && /tmp/appimagetool --appimage-extract && \
mv squashfs-root /opt/appimagetool && \
ln -sf /opt/appimagetool/AppRun /usr/local/bin/appimagetool && \
rm /tmp/appimagetool
# ── file utility (needed by linuxdeploy for ELF detection) ──────────────────
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends file patchelf zip curl jq && \
rm -rf /var/lib/apt/lists/*
# ── gitlab-runner (shell executor) ───────────────────────────────────────────
RUN wget -q https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 \
-O /usr/local/bin/gitlab-runner && \
+63 -28
View File
@@ -1,12 +1,13 @@
#!/bin/bash
# Package Windows build as a portable directory with all DLLs
# Usage: package-windows.sh <build-dir> <qt-dir> <mingw-sysroot> <output-dir>
# Usage: package-windows.sh <build-dir> <qt-dir> <mingw-sysroot> <output-dir> [arch]
set -euo pipefail
BUILD_DIR="${1:?Usage: package-windows.sh <build-dir> <qt-dir> <mingw-sysroot> <output-dir>}"
BUILD_DIR="${1:?Usage: package-windows.sh <build-dir> <qt-dir> <mingw-sysroot> <output-dir> [arch]}"
QT_DIR="${2:?}"
MINGW_SYSROOT="${3:?}"
OUTPUT_DIR="${4:?}"
ARCH="${5:-x86_64}"
PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
DIST_DIR="${BUILD_DIR}/dist"
@@ -21,45 +22,79 @@ cp "$BUILD_DIR/asteria-qt.exe" "$DIST_DIR/"
# windeployqt6 from the cross-compiled Qt may not work on Linux host,
# so we manually copy the required DLLs
# Qt DLLs — copy all Qt6*.dll to avoid missing transitive dependencies
cp "$QT_DIR/bin/"Qt6*.dll "$DIST_DIR/" 2>/dev/null || true
# Qt DLLs — copy all Qt6*.dll and related runtime DLLs from Qt bin directory
cp "$QT_DIR/bin/"*.dll "$DIST_DIR/" 2>/dev/null || true
# Qt plugins (support standard Qt layout and MSYS2 share/qt6 layout)
PLUGIN_DIR="$QT_DIR/plugins"
if [ ! -d "$PLUGIN_DIR" ] && [ -d "$QT_DIR/share/qt6/plugins" ]; then
PLUGIN_DIR="$QT_DIR/share/qt6/plugins"
fi
# Qt plugins
mkdir -p "$DIST_DIR/platforms"
cp "$QT_DIR/plugins/platforms/qwindows.dll" "$DIST_DIR/platforms/" 2>/dev/null || true
cp "$PLUGIN_DIR/platforms/qwindows.dll" "$DIST_DIR/platforms/" 2>/dev/null || true
mkdir -p "$DIST_DIR/imageformats"
cp "$QT_DIR/plugins/imageformats/"*.dll "$DIST_DIR/imageformats/" 2>/dev/null || true
cp "$PLUGIN_DIR/imageformats/"*.dll "$DIST_DIR/imageformats/" 2>/dev/null || true
mkdir -p "$DIST_DIR/iconengines"
cp "$QT_DIR/plugins/iconengines/"*.dll "$DIST_DIR/iconengines/" 2>/dev/null || true
cp "$PLUGIN_DIR/iconengines/"*.dll "$DIST_DIR/iconengines/" 2>/dev/null || true
mkdir -p "$DIST_DIR/tls"
cp "$QT_DIR/plugins/tls/"*.dll "$DIST_DIR/tls/" 2>/dev/null || true
cp "$PLUGIN_DIR/tls/"*.dll "$DIST_DIR/tls/" 2>/dev/null || true
if [ -d "$PLUGIN_DIR/styles" ]; then
mkdir -p "$DIST_DIR/styles"
cp "$PLUGIN_DIR/styles/"*.dll "$DIST_DIR/styles/" 2>/dev/null || true
fi
# QML modules (support standard Qt layout and MSYS2 share/qt6 layout)
QML_DIR="$QT_DIR/qml"
if [ ! -d "$QML_DIR" ] && [ -d "$QT_DIR/share/qt6/qml" ]; then
QML_DIR="$QT_DIR/share/qt6/qml"
fi
# QML modules
mkdir -p "$DIST_DIR/qml"
for mod in QtQuick QtQml Qt5Compat; do
if [ -d "$QT_DIR/qml/$mod" ]; then
cp -r "$QT_DIR/qml/$mod" "$DIST_DIR/qml/"
for mod in QtCore Qt QtQuick QtQml Qt5Compat; do
if [ -d "$QML_DIR/$mod" ]; then
cp -r "$QML_DIR/$mod" "$DIST_DIR/qml/"
fi
done
# MinGW runtime DLLs
MINGW_DLLS=(
libgcc_s_seh-1.dll
libstdc++-6.dll
libwinpthread-1.dll
)
# Architecture-specific runtime DLLs
if [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then
PKG_NAME="asteria-qt-windows-arm64"
for dll in "${MINGW_DLLS[@]}"; do
find /usr/lib/gcc/x86_64-w64-mingw32/ -name "$dll" -exec cp {} "$DIST_DIR/" \; 2>/dev/null || true
if [ ! -f "$DIST_DIR/$dll" ] && [ -f "/usr/x86_64-w64-mingw32/lib/$dll" ]; then
cp "/usr/x86_64-w64-mingw32/lib/$dll" "$DIST_DIR/"
fi
done
# LLVM-MinGW runtime DLLs for ARM64
ARM64_DLLS=(
libc++.dll
libunwind.dll
libwinpthread-1.dll
)
for dll in "${ARM64_DLLS[@]}"; do
find /opt/llvm-mingw/aarch64-w64-mingw32/ -name "$dll" -exec cp {} "$DIST_DIR/" \; 2>/dev/null || true
if [ ! -f "$DIST_DIR/$dll" ] && [ -f "$MINGW_SYSROOT/bin/$dll" ]; then
cp "$MINGW_SYSROOT/bin/$dll" "$DIST_DIR/"
fi
done
else
PKG_NAME="asteria-qt-windows"
# Third-party DLLs from sysroot
# MinGW-w64 runtime DLLs for x86_64
MINGW_DLLS=(
libgcc_s_seh-1.dll
libstdc++-6.dll
libwinpthread-1.dll
)
for dll in "${MINGW_DLLS[@]}"; do
find /usr/lib/gcc/x86_64-w64-mingw32/ -name "$dll" -exec cp {} "$DIST_DIR/" \; 2>/dev/null || true
if [ ! -f "$DIST_DIR/$dll" ] && [ -f "/usr/x86_64-w64-mingw32/lib/$dll" ]; then
cp "/usr/x86_64-w64-mingw32/lib/$dll" "$DIST_DIR/"
fi
done
fi
# Third-party DLLs from sysroot (if dynamically built)
if [ -f "$MINGW_SYSROOT/lib/libuchardet.dll" ]; then
cp "$MINGW_SYSROOT/lib/libuchardet.dll" "$DIST_DIR/"
elif [ -f "$MINGW_SYSROOT/bin/libuchardet.dll" ]; then
@@ -74,5 +109,5 @@ Qml2Imports = qml
EOF
# Output flat directory — GitLab zips the artifact directory on download
mkdir -p "$OUTPUT_DIR/asteria-qt-windows"
cp -r "$DIST_DIR/"* "$OUTPUT_DIR/asteria-qt-windows/"
mkdir -p "$OUTPUT_DIR/$PKG_NAME"
cp -r "$DIST_DIR/"* "$OUTPUT_DIR/$PKG_NAME/"
+20
View File
@@ -0,0 +1,20 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER aarch64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER aarch64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER aarch64-w64-mingw32-windres)
# Append default sysroot paths. list(APPEND) preserves any paths already set via
# -DCMAKE_FIND_ROOT_PATH on the cmake command line (e.g. the Qt Windows ARM64 install dir),
# while plain set() would silently override them and break find_package(Qt6).
list(APPEND CMAKE_FIND_ROOT_PATH /opt/mingw-arm64-sysroot /opt/llvm-mingw/aarch64-w64-mingw32)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
# Point pkg-config at the MinGW ARM64 sysroot so it finds cross-compiled .pc files
set(ENV{PKG_CONFIG_LIBDIR} "$ENV{MINGW_ARM64_SYSROOT}/lib/pkgconfig")
set(ENV{PKG_CONFIG_PATH} "")
+10 -3
View File
@@ -1,9 +1,16 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
# Explicitly prefer GCC toolchain in /usr/bin when available to prevent collision with llvm-mingw
if(EXISTS "/usr/bin/x86_64-w64-mingw32-gcc")
set(CMAKE_C_COMPILER /usr/bin/x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER /usr/bin/x86_64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER /usr/bin/x86_64-w64-mingw32-windres)
else()
set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
endif()
# Append default sysroot paths. list(APPEND) preserves any paths already set via
# -DCMAKE_FIND_ROOT_PATH on the cmake command line (e.g. the Qt Windows install dir),
+49 -14
View File
@@ -1,24 +1,33 @@
#!/bin/bash
# Run CI build/package jobs locally using podman or docker.
# Usage: test-ci-windows.sh [--build-image] [--linux]
# Usage: test-ci-windows.sh [--build-image] [--linux] [--arm64]
# --build-image build the CI image from Dockerfile instead of pulling the prebuilt one
# --linux also run build-linux + package-linux in addition to Windows jobs
# --arm64 also run build-windows-arm64 + package-windows-arm64
set -euo pipefail
export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
OUTPUT_DIR="$PROJECT_DIR/ci-output"
DOCKERFILE="$PROJECT_DIR/docker/Dockerfile.build"
PREBUILT_IMAGE="registry.gitlab.com/asteria-bookreader/asteria-qt/build-env:latest"
PREBUILT_IMAGE="${PREBUILT_IMAGE:-registry.gitlab.com/asteria-bookreader/asteria-qt/build-env:latest}"
IMAGE_TAG="$PREBUILT_IMAGE"
BUILD_IMAGE=false
RUN_LINUX=false
RUN_X86_64=true
RUN_ARM64=false
for arg in "$@"; do
case "$arg" in
--build-image) BUILD_IMAGE=true; IMAGE_TAG="asteria-qt-ci-local:latest" ;;
--linux) RUN_LINUX=true ;;
*) echo "Unknown argument: $arg"; exit 1 ;;
while [[ $# -gt 0 ]]; do
case "$1" in
--build-image) BUILD_IMAGE=true; IMAGE_TAG="asteria-qt-ci-local:latest"; shift ;;
--image) IMAGE_TAG="$2"; shift 2 ;;
--image=*) IMAGE_TAG="${1#*=}"; shift ;;
--linux) RUN_LINUX=true; shift ;;
--arm64) RUN_ARM64=true; shift ;;
--only-arm64) RUN_ARM64=true; RUN_X86_64=false; shift ;;
*) echo "Unknown argument: $1"; exit 1 ;;
esac
done
@@ -41,9 +50,11 @@ if [ "$BUILD_IMAGE" = true ]; then
-t "$IMAGE_TAG" \
-f "$DOCKERFILE" \
"$PROJECT_DIR"
else
elif ! "$RUNTIME" image inspect "$IMAGE_TAG" &>/dev/null; then
echo "==> Pulling prebuilt CI image: $IMAGE_TAG"
"$RUNTIME" pull --platform linux/amd64 "$IMAGE_TAG"
else
echo "==> Using local image: $IMAGE_TAG"
fi
rm -rf "$OUTPUT_DIR"
@@ -67,9 +78,10 @@ run_in_container() {
'
}
# ── Windows build ────────────────────────────────────────────────────────────
echo "==> build-windows"
CI_SCRIPT='
# ── Windows x86_64 build ─────────────────────────────────────────────────────
if [ "$RUN_X86_64" = true ]; then
echo "==> build-windows (x86_64)"
CI_SCRIPT='
PKG_CONFIG_PATH="${MINGW_SYSROOT}/lib/pkgconfig" cmake -B build-windows -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/src/scripts/mingw-w64-toolchain.cmake \
@@ -80,12 +92,35 @@ cmake --build build-windows --target asteria-qt
cp -r build-windows /out/build-windows
' run_in_container -v "$OUTPUT_DIR:/out"
echo "==> package-windows"
CI_SCRIPT='
echo "==> package-windows (x86_64)"
CI_SCRIPT='
cp -r /out/build-windows build-windows
chmod +x packaging/package-windows.sh
packaging/package-windows.sh build-windows "${QT_WINDOWS_DIR}" "${MINGW_SYSROOT}" /out
packaging/package-windows.sh build-windows "${QT_WINDOWS_DIR}" "${MINGW_SYSROOT}" /out x86_64
' run_in_container -v "$OUTPUT_DIR:/out"
fi
# ── Windows ARM64 build (optional) ───────────────────────────────────────────
if [ "$RUN_ARM64" = true ]; then
echo "==> build-windows-arm64"
CI_SCRIPT='
PKG_CONFIG_PATH="${MINGW_ARM64_SYSROOT}/lib/pkgconfig" cmake -B build-windows-arm64 -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/src/scripts/mingw-w64-arm64-toolchain.cmake \
-DCMAKE_PREFIX_PATH="${QT_WINDOWS_ARM64_DIR};${MINGW_ARM64_SYSROOT}" \
-DCMAKE_FIND_ROOT_PATH="${QT_WINDOWS_ARM64_DIR};${MINGW_ARM64_SYSROOT}" \
-DQT_HOST_PATH="${QT_LINUX_DIR}"
cmake --build build-windows-arm64 --target asteria-qt
cp -r build-windows-arm64 /out/build-windows-arm64
' run_in_container -v "$OUTPUT_DIR:/out"
echo "==> package-windows-arm64"
CI_SCRIPT='
cp -r /out/build-windows-arm64 build-windows-arm64
chmod +x packaging/package-windows.sh
packaging/package-windows.sh build-windows-arm64 "${QT_WINDOWS_ARM64_DIR}" "${MINGW_ARM64_SYSROOT}" /out arm64
' run_in_container -v "$OUTPUT_DIR:/out"
fi
# ── Linux build (optional) ───────────────────────────────────────────────────
if [ "$RUN_LINUX" = true ]; then