moar ci changes

This commit is contained in:
Agel committed 2026-11-13 10:56:08 +01:00
1 parent 5940d86ed2
commit 1ef94b910a
19 files changed
+1310 -660

No files matched your search

+60 -10
View File
@@ -23,6 +23,7 @@ workflow:
- docker/Dockerfile.build
- scripts/download-mingw-arm64-qt.py
- scripts/install-deps-ubuntu.sh
- scripts/linux-arm64-toolchain.cmake
- scripts/mingw-w64-toolchain.cmake
- scripts/mingw-w64-arm64-toolchain.cmake
variables:
@@ -52,14 +53,14 @@ build-docker:
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
script:
- docker build
--build-arg QT_VERSION=6.10.3
--build-arg QT_VERSION=6.12.0
-t "${DOCKER_IMAGE}"
-f docker/Dockerfile.build .
- docker push "${DOCKER_IMAGE}"
rules:
- if: $CI_PIPELINE_TYPE == "image-rebuild"
# ── Linux native build ─────────────────────────────────────────────────────────
# ── Linux native build (x86_64) ────────────────────────────────────────────────
build-linux:
interruptible: true
tags:
@@ -80,7 +81,31 @@ build-linux:
when: never
- when: on_success
# ── Windows cross-compile build (MinGW-w64 x86_64) ───────────────────────────
# ── Linux cross-compile build (ARM64) ──────────────────────────────────────────
build-linux-arm64:
interruptible: true
tags:
- linux-qt
stage: build
script:
- cmake -B build-linux-arm64 -G Ninja
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_TOOLCHAIN_FILE="${CI_PROJECT_DIR}/scripts/linux-arm64-toolchain.cmake"
-DCMAKE_PREFIX_PATH="${QT_LINUX_ARM64_DIR}"
-DQT_HOST_PATH="${QT_LINUX_DIR}"
- cmake --build build-linux-arm64 --target asteria-qt
artifacts:
name: "asteria-qt-linux-arm64-${CI_COMMIT_SHORT_SHA}"
paths:
- build-linux-arm64/asteria-qt
expire_in: 1 day
when: on_success
rules:
- if: $CI_PIPELINE_TYPE == "image-rebuild"
when: never
- when: on_success
# ── Windows cross-compile build (LLVM-MinGW x86_64) ───────────────────────────
build-windows:
interruptible: true
tags:
@@ -142,7 +167,7 @@ build-macos:
- export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
- export PKG_CONFIG_PATH="$(brew --prefix libarchive)/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
- cmake -B build-macos -G Ninja -DCMAKE_BUILD_TYPE=Release
-DCMAKE_PREFIX_PATH="${QT_MACOS_DIR:-/opt/qt/6.10.3/macos}"
-DCMAKE_PREFIX_PATH="${QT_MACOS_DIR:-/opt/qt/6.12.0/macos}"
- cmake --build build-macos --target asteria-qt
artifacts:
name: "asteria-qt-macos-${CI_COMMIT_SHORT_SHA}"
@@ -185,7 +210,7 @@ test-macos:
- export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
- export PKG_CONFIG_PATH="$(brew --prefix libarchive)/lib/pkgconfig:${PKG_CONFIG_PATH:-}"
- cmake -B build-macos -G Ninja -DCMAKE_BUILD_TYPE=Release
-DCMAKE_PREFIX_PATH="${QT_MACOS_DIR:-/opt/qt/6.10.3/macos}"
-DCMAKE_PREFIX_PATH="${QT_MACOS_DIR:-/opt/qt/6.12.0/macos}"
- cmake --build build-macos
- QT_QPA_PLATFORM=offscreen ctest --test-dir build-macos --output-on-failure
rules:
@@ -193,7 +218,7 @@ test-macos:
when: never
- when: on_success
# ── Package Linux as AppImage ─────────────────────────────────────────────
# ── Package Linux x86_64 as AppImage ───────────────────────────────────────────
package-linux:
interruptible: true
tags:
@@ -204,7 +229,7 @@ package-linux:
- test-linux
script:
- chmod +x packaging/package-linux.sh
- packaging/package-linux.sh build-linux "${QT_LINUX_DIR}" .
- packaging/package-linux.sh build-linux "${QT_LINUX_DIR}" . x86_64
artifacts:
name: "asteria-qt-linux-appimage-${CI_COMMIT_SHORT_SHA}"
paths:
@@ -216,6 +241,29 @@ package-linux:
when: never
- when: on_success
# ── Package Linux ARM64 as AppImage ────────────────────────────────────────────
package-linux-arm64:
interruptible: true
tags:
- linux-qt
stage: package
needs:
- build-linux-arm64
- test-linux
script:
- chmod +x packaging/package-linux.sh
- packaging/package-linux.sh build-linux-arm64 "${QT_LINUX_ARM64_DIR}" . arm64
artifacts:
name: "asteria-qt-linux-arm64-appimage-${CI_COMMIT_SHORT_SHA}"
paths:
- Asteria-arm64.AppImage
expire_in: 1 day
when: on_success
rules:
- if: $CI_PIPELINE_TYPE == "image-rebuild"
when: never
- when: on_success
# ── Package Windows x86_64 as portable zip ───────────────────────────────────
package-windows:
interruptible: true
@@ -276,7 +324,7 @@ package-macos:
script:
- export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
- chmod +x packaging/package-macos.sh
- packaging/package-macos.sh build-macos "${QT_MACOS_DIR:-/opt/qt/6.10.3/macos}" .
- packaging/package-macos.sh build-macos "${QT_MACOS_DIR:-/opt/qt/6.12.0/macos}" .
artifacts:
name: "asteria-qt-macos-dmg-${CI_COMMIT_SHORT_SHA}"
paths:
@@ -295,6 +343,7 @@ update-wiki:
- linux-qt
needs:
- package-linux
- package-linux-arm64
- package-windows
- package-windows-arm64
- job: package-macos
@@ -310,6 +359,7 @@ update-wiki:
- WIKI_URL="${API_URL}/wikis/home"
- ARTIFACTS_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/download"
- LINUX_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw/Asteria-x86_64.AppImage?job=package-linux"
- LINUX_ARM64_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw/Asteria-arm64.AppImage?job=package-linux-arm64"
- WINDOWS_URL="${ARTIFACTS_URL}?job=package-windows"
- WINDOWS_ARM64_URL="${ARTIFACTS_URL}?job=package-windows-arm64"
- MACOS_URL="${PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_NAME}/raw/Asteria.dmg?job=package-macos"
@@ -318,9 +368,9 @@ update-wiki:
--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) |\n| Windows (ARM64) | [Portable zip](%s) |\n| macOS | [DMG](%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| Linux (ARM64) | [AppImage](%s) |\n| Windows (x86_64) | [Portable zip](%s) |\n| Windows (ARM64) | [Portable zip](%s) |\n| macOS | [DMG](%s) |' \
"${CI_PIPELINE_ID}" "${CI_PIPELINE_URL}" "${CI_COMMIT_REF_NAME}" "${CI_COMMIT_SHORT_SHA}" \
"${LINUX_URL}" "${WINDOWS_URL}" "${WINDOWS_ARM64_URL}" "${MACOS_URL}")
"${LINUX_URL}" "${LINUX_ARM64_URL}" "${WINDOWS_URL}" "${WINDOWS_ARM64_URL}" "${MACOS_URL}")
if [ "${HTTP_CODE}" = "200" ]; then
WIKI_CONTENT=$(jq -r '.content' /tmp/wiki.json)
+43 -17
View File
@@ -51,11 +51,11 @@ Full target format list:
## Build & Install
### Dependencies
- Qt 6.10+ components: `Core`, `Gui`, `Qml`, `Quick`, `Widgets`, `Concurrent`, `Svg`, `QuickControls2`, `Test`, `Xml`, `Network`, optional `DBus`.
- Qt 6.12+ 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 (x86_64)
Qt 6.10.3 at `C:\msys64\opt\qt\6.10.3\mingw_64`. MinGW toolchain at `C:\msys64\mingw64\bin\`:
### Windows Build Environment (x86_64 Native MSYS2)
Qt 6 at `C:\msys64\opt\qt\6.12.0\mingw_64` (or `C:\msys64\mingw64`). MinGW toolchain at `C:\msys64\mingw64\bin\`:
```bash
PATH="/c/msys64/mingw64/bin:$PATH" "C:/msys64/mingw64/bin/cmake.exe" \
-S . -B build -G Ninja \
@@ -63,35 +63,61 @@ PATH="/c/msys64/mingw64/bin:$PATH" "C:/msys64/mingw64/bin/cmake.exe" \
-DCMAKE_MAKE_PROGRAM="C:/msys64/mingw64/bin/ninja.exe" \
-DCMAKE_C_COMPILER="C:/msys64/mingw64/bin/gcc.exe" \
-DCMAKE_CXX_COMPILER="C:/msys64/mingw64/bin/g++.exe" \
-DCMAKE_PREFIX_PATH="c:\msys64\opt\qt\6.10.3\mingw_64"
-DCMAKE_PREFIX_PATH="c:\msys64\opt\qt\6.12.0\mingw_64"
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
PATH="/c/msys64/opt/qt/6.12.0/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 (transitive runtime dependencies resolved automatically via `scripts/download-mingw-arm64-qt.py`):
### Windows Cross-Compilation Environment (x86_64 & ARM64 on Linux host / CI)
Cross-compiled using `llvm-mingw` (`x86_64-w64-mingw32` and `aarch64-w64-mingw32`) and prebuilt MSYS2 (`clang64` and `clangarm64`) Qt 6.12.0 + third-party library packages (`libarchive`, `libiconv`, `minizip`, `uchardet`, `zlib`), resolved with full transitive runtime dependencies via `scripts/download-mingw-arm64-qt.py --arch {x86_64,arm64}`:
```bash
# Windows x86_64
PKG_CONFIG_PATH="/opt/mingw-sysroot/lib/pkgconfig" cmake -B build-windows -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=scripts/mingw-w64-toolchain.cmake \
-DCMAKE_PREFIX_PATH="/opt/qt/6.12.0/mingw_64;/opt/mingw-sysroot" \
-DCMAKE_FIND_ROOT_PATH="/opt/qt/6.12.0/mingw_64;/opt/mingw-sysroot" \
-DQT_HOST_PATH="/opt/qt/6.12.0/gcc_64"
cmake --build build-windows --target asteria-qt
# Windows ARM64
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"
-DCMAKE_PREFIX_PATH="/opt/qt/6.12.0/mingw_arm64;/opt/mingw-arm64-sysroot" \
-DCMAKE_FIND_ROOT_PATH="/opt/qt/6.12.0/mingw_arm64;/opt/mingw-arm64-sysroot" \
-DQT_HOST_PATH="/opt/qt/6.12.0/gcc_64"
cmake --build build-windows-arm64 --target asteria-qt
```
Packaging (includes automated PE binary DLL dependency verification via `scripts/verify-windows-dlls.py`):
Packaging (includes automated transitive PE DLL bundling and import verification via `scripts/verify-windows-dlls.py`):
```bash
packaging/package-windows.sh build-windows-arm64 /opt/qt/6.10.3/mingw_arm64 /opt/mingw-arm64-sysroot dist arm64
packaging/package-windows.sh build-windows /opt/qt/6.12.0/mingw_64 /opt/mingw-sysroot dist x86_64
packaging/package-windows.sh build-windows-arm64 /opt/qt/6.12.0/mingw_arm64 /opt/mingw-arm64-sysroot dist arm64
```
### Linux Build Environment (Ubuntu 24.04)
### Linux Build Environment (Ubuntu 24.04 — x86_64 & ARM64)
Setup via `sudo scripts/install-deps-ubuntu.sh` (add `--with-arm64` to also install Ubuntu `arm64` multiarch packages and `linux_gcc_arm64` Qt 6.12.0):
```bash
# Native x86_64 build & tests
cmake -S . -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH=/opt/qt/6.10.3/gcc_64
-DCMAKE_PREFIX_PATH=/opt/qt/6.12.0/gcc_64
ninja -C build
ctest --test-dir build --output-on-failure
# Cross-compiled ARM64 build
cmake -S . -B build-linux-arm64 -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=scripts/linux-arm64-toolchain.cmake \
-DCMAKE_PREFIX_PATH=/opt/qt/6.12.0/gcc_arm64 \
-DQT_HOST_PATH=/opt/qt/6.12.0/gcc_64
cmake --build build-linux-arm64 --target asteria-qt
```
AppImage Packaging (uses `scripts/bundle-linux-appdir.py` + `appimagetool` for both `x86_64` and `arm64`):
```bash
packaging/package-linux.sh build-linux /opt/qt/6.12.0/gcc_64 dist x86_64
packaging/package-linux.sh build-linux-arm64 /opt/qt/6.12.0/gcc_arm64 dist arm64
```
### macOS Build Environment
@@ -100,7 +126,7 @@ scripts/install-deps-macos.sh
export PKG_CONFIG_PATH="$(brew --prefix libarchive)/lib/pkgconfig:$PKG_CONFIG_PATH"
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH=/opt/qt/6.10.3/macos
-DCMAKE_PREFIX_PATH=/opt/qt/6.12.0/macos
cmake --build build --parallel
ctest --test-dir build --output-on-failure
```
@@ -108,7 +134,7 @@ ctest --test-dir build --output-on-failure
Packaging:
```bash
packaging/package-macos.sh build /opt/qt/6.10.3/macos dist
packaging/package-macos.sh build /opt/qt/6.12.0/macos dist
```
Local GitLab Runner (shell executor):
```bash
@@ -372,7 +398,7 @@ tests/
---
## Qt Conventions
- **Qt 6.10+** preferred — no Qt5 compat shims.
- **Qt 6.12+** preferred — no Qt5 compat shims.
- All UI in **QML**; C++ for logic, parsing, and heavy computation.
- Expose C++ backend singletons declaratively in the `Asteria` QML module via `QML_FOREIGN` wrappers (`QmlRegistrations.h`) and `QML_ELEMENT` for custom items (`KnuthPlassItem`). Avoid runtime `rootContext()->setContextProperty()` so `qmllint` and `qmlcachegen` statically type-check all bindings and properties ahead of time.
- Main window starts with opacity 0 and ticks to 1 on a short timer to prevent white window flash during initial render.
+2 -2
View File
@@ -25,7 +25,7 @@
"binaryDir": "${sourceDir}/cmake-build-debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_PREFIX_PATH": "/opt/qt/6.10.3/macos"
"CMAKE_PREFIX_PATH": "/opt/qt/6.12.0/macos"
}
},
{
@@ -36,7 +36,7 @@
"binaryDir": "${sourceDir}/cmake-build-release",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_PREFIX_PATH": "/opt/qt/6.10.3/macos"
"CMAKE_PREFIX_PATH": "/opt/qt/6.12.0/macos"
}
}
],
+29 -22
View File
@@ -3,13 +3,13 @@
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 (x86_64 and ARM64), Linux, and macOS.
**Target platforms:** Windows (x86_64 and ARM64), Linux (x86_64 and ARM64), and macOS.
## Prerequisites
- **Qt 6.10.x** (installed via `aqtinstall` to `/opt/qt`; Ubuntu apt only ships 6.4 which is too old)
- **Qt 6.12+** (`6.12.0` installed by default via `aqtinstall` to `/opt/qt`)
- **CMake 3.16+**
- **C++17 compiler** — GCC 10+ or Clang 12+ on Linux; MinGW-w64 (GCC) via MSYS2 on Windows
- **C++17 compiler** — GCC 10+ or Clang 12+ on Linux; MinGW-w64 (GCC/Clang) via MSYS2 or LLVM-MinGW on Windows
## Installing Dependencies
@@ -17,18 +17,18 @@ Reimplementation of [asteria-bookreader](../asteria-bookreader) (Electron/React)
```bash
sudo scripts/install-deps-ubuntu.sh
# Optional: include Linux ARM64 cross-compilation dependencies and Qt 6.12.0 (gcc_arm64)
sudo scripts/install-deps-ubuntu.sh --with-arm64
```
The script installs Qt 6.10.3 via `aqtinstall` to `/opt/qt/6.10.3/gcc_64`, plus the following apt packages:
The script installs Qt 6.12.0 via `aqtinstall` to `/opt/qt/6.12.0/gcc_64`, plus the following apt packages:
| Group | Packages | Required? |
|---|---|---|
| Build tools | `build-essential`, `cmake`, `ninja-build`, `git` | Required |
| Qt compile deps | `libgl1-mesa-dev`, `libxkbcommon-dev` | Required |
| Encoding | `libuchardet-dev` | Required (TXT encoding detection) |
| Archive | `libminizip-dev` | Required (EPUB/ZIP) |
| DjVu | `libdjvulibre-dev` | Optional (DjVu support) |
| DOC | `libwpd-dev` | Optional (legacy .doc support) |
| Build tools | `build-essential`, `cmake`, `ninja-build`, `git`, `pkg-config` | Required |
| Qt compile deps | `libgl-dev`, `libegl-dev`, `libxkbcommon-dev`, `libfontconfig1-dev`, `libfreetype-dev`, `libdbus-1-dev` | Required |
| Encoding | `libuchardet-dev` | Required (TXT/FB2 encoding detection) |
| Archive | `libminizip-dev`, `libarchive-dev`, `zlib1g-dev` | Required (EPUB/FBZ/CBZ/CBR) |
### Windows
@@ -65,7 +65,7 @@ cd /c/path/to/asteria-qt
bash scripts/install-deps-windows.sh
```
The script installs Qt 6.10.3 via `aqtinstall` to `/opt/qt/6.10.3/mingw_64`, plus the following MSYS2 packages:
The script installs Qt 6.12.0 via `aqtinstall` to `/opt/qt/6.12.0/mingw_64`, plus the following MSYS2 packages:
- `mingw-w64-x86_64-gcc` — GCC toolchain
- `mingw-w64-x86_64-zlib` — Compression library
@@ -82,7 +82,7 @@ Verify the installation:
```bash
gcc --version
cmake --version
ls /opt/qt/6.10.3/mingw_64/bin # Should show Qt binaries like qmake6
ls /opt/qt/6.12.0/mingw_64/bin # Should show Qt binaries like qmake6
```
**Step 4 — Clone the repository**
@@ -96,23 +96,30 @@ cd asteria-qt
All build commands run in the **MSYS2 MINGW64** shell on Windows, or a regular terminal on Linux.
On Linux, pass `-DCMAKE_PREFIX_PATH=/opt/qt/6.10.3/gcc_64` so CMake finds the aqt-installed Qt. On Windows, pass `-DCMAKE_PREFIX_PATH=c:\msys64\opt\qt\6.10.3\mingw_64` for the same reason.
On Linux, pass `-DCMAKE_PREFIX_PATH=/opt/qt/6.12.0/gcc_64` so CMake finds the aqt-installed Qt. On Windows, pass `-DCMAKE_PREFIX_PATH=c:\msys64\opt\qt\6.12.0\mingw_64` for the same reason.
### Command Line
```bash
# Debug build (Linux)
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/opt/qt/6.10.3/gcc_64
# Debug build (Linux x86_64)
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/opt/qt/6.12.0/gcc_64
cmake --build build --parallel
# Debug build (Windows)
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=c:\msys64\opt\qt\6.10.3\mingw_64
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=c:\msys64\opt\qt\6.12.0\mingw_64
cmake --build build --parallel
# Release build (Linux)
cmake -B build-release -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/opt/qt/6.10.3/gcc_64
# Release build (Linux x86_64)
cmake -B build-release -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/opt/qt/6.12.0/gcc_64
cmake --build build-release --parallel
# Release build (Linux ARM64 cross-compile)
cmake -B build-linux-arm64 -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=scripts/linux-arm64-toolchain.cmake \
-DCMAKE_PREFIX_PATH=/opt/qt/6.12.0/gcc_arm64 \
-DQT_HOST_PATH=/opt/qt/6.12.0/gcc_64
cmake --build build-linux-arm64 --parallel
# Run tests
ctest --test-dir build --output-on-failure
```
@@ -132,9 +139,9 @@ ctest --test-dir build --output-on-failure
2. Go to **Settings → Build, Execution, Deployment → CMake**
3. In the **Debug** and **Release** profiles, add to **CMake options**:
```
-DCMAKE_PREFIX_PATH=/opt/qt/6.10.3/gcc_64
-DCMAKE_PREFIX_PATH=/opt/qt/6.12.0/gcc_64
```
This is where `install-deps-ubuntu.sh` installs Qt 6.10.3 via aqtinstall.
This is where `install-deps-ubuntu.sh` installs Qt 6.12.0 via aqtinstall.
4. CLion auto-detects the system GCC toolchain — no toolchain configuration needed
5. To add a **Release** profile: click `+` to duplicate, change **Build type** to `Release`, same CMake options
6. Build: `Ctrl+F9` | Run: `Shift+F10`
@@ -150,7 +157,7 @@ ctest --test-dir build --output-on-failure
- In the Debug profile, set **Toolchain** to the MSYS2 MinGW toolchain created above
3. In the **Debug** and **Release** profiles, add to **CMake options**:
```
-DCMAKE_PREFIX_PATH=c:\msys64\opt\qt\6.10.3\mingw_64
-DCMAKE_PREFIX_PATH=c:\msys64\opt\qt\6.12.0\mingw_64
```
3. Build: `Ctrl+F9` | Run: `Shift+F10`
@@ -166,5 +173,5 @@ ctest --test-dir build --output-on-failure
1. File → Open File or Project → select `CMakeLists.txt`
2. Configure the kit under Edit → Preferences → Kits
3. On Windows: add a kit pointing to MSYS2's Qt (`C:\msys64\mingw64`) and MinGW compiler and `-DCMAKE_PREFIX_PATH=c:\msys64\opt\qt\6.10.3\mingw_64` to the CMake options
3. On Windows: add a kit pointing to MSYS2's Qt (`C:\msys64\mingw64`) and MinGW compiler and `-DCMAKE_PREFIX_PATH=c:\msys64\opt\qt\6.12.0\mingw_64` to the CMake options
4. Build: `Ctrl+B` / `⌘B` | Run: `Ctrl+R` / `⌘R`
+32 -212
View File
@@ -1,246 +1,66 @@
FROM ubuntu:24.04
ARG QT_VERSION=6.10.3
ARG QT_VERSION=6.12.0
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}
ENV QT_INSTALL_DIR=${QT_INSTALL_DIR}
ENV QT_LINUX_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64
ENV QT_LINUX_ARM64_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/gcc_arm64
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=${QT_WINDOWS_DIR}
ENV MINGW_ARM64_SYSROOT=${QT_WINDOWS_ARM64_DIR}
# ── Build tools & native deps ──────────────────────────────────────────────────
RUN apt-get update -qq && \
apt-get install -y --no-install-recommends \
python3 python3-pip \
cmake ninja-build pkg-config git \
build-essential libgl1-mesa-dev \
gcc g++ mingw-w64 \
libuchardet-dev \
zlib1g-dev libquazip1-qt6-dev libminizip-dev libarchive-dev \
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
# ── Linux x86_64 & ARM64 dependencies + Qt 6 (via install-deps-ubuntu.sh) ──────
COPY scripts/install-deps-ubuntu.sh /tmp/install-deps-ubuntu.sh
RUN chmod +x /tmp/install-deps-ubuntu.sh && \
QT_VERSION=${QT_VERSION} QT_INSTALL_DIR=${QT_INSTALL_DIR} /tmp/install-deps-ubuntu.sh --with-arm64 && \
rm -rf /tmp/install-deps-ubuntu.sh /var/lib/apt/lists/*
# ── aqtinstall ─────────────────────────────────────────────────────────────────
RUN pip3 install --quiet --break-system-packages aqtinstall
# ── Qt 6 for Linux (native build + host tools for cross-compile) ───────────────
RUN aqt install-qt linux desktop ${QT_VERSION} linux_gcc_64 \
-m qtimageformats qtpdf qtwebview \
--outputdir ${QT_INSTALL_DIR}
# ── 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}
# ── llvm-mingw for Windows ARM64 (aarch64-w64-mingw32) ────────────────────────
# ── llvm-mingw cross-compiler (targets both x86_64-w64-mingw32 & 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"
ENV PATH="/opt/llvm-mingw/bin:${PATH}"
# ── Qt 6 for Windows ARM64 (MinGW cross-compile target) ────────────────────────
# ── Windows x86_64 & ARM64 prebuilt MSYS2 sysroots (Qt 6 + third-party libs) ───
COPY scripts/download-mingw-arm64-qt.py /tmp/download-mingw-arm64-qt.py
RUN chmod +x /tmp/download-mingw-arm64-qt.py && \
python3 /tmp/download-mingw-arm64-qt.py --dest "${QT_INSTALL_DIR}/${QT_VERSION}/mingw_arm64" && \
python3 /tmp/download-mingw-arm64-qt.py --arch x86_64 --dest "${QT_WINDOWS_DIR}" && \
python3 /tmp/download-mingw-arm64-qt.py --arch arm64 --dest "${QT_WINDOWS_ARM64_DIR}" && \
ln -sfn "${QT_WINDOWS_DIR}" /opt/mingw-sysroot && \
ln -sfn "${QT_WINDOWS_ARM64_DIR}" /opt/mingw-arm64-sysroot && \
rm /tmp/download-mingw-arm64-qt.py
# ── Toolchain files ────────────────────────────────────────────────────────────
# ── CMake cross-compilation 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
COPY scripts/linux-arm64-toolchain.cmake /opt/linux-arm64-toolchain.cmake
# ── 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 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 \
-DCMAKE_INSTALL_PREFIX=/opt/mingw-sysroot \
-DBUILD_SHARED_LIBS=OFF && \
cmake --build /tmp/uchardet-build && \
cmake --install /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 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 && \
\
# x86_64 zlib
cd /tmp/zlib-${ZLIB_VERSION} && \
make -f win32/Makefile.gcc \
PREFIX=x86_64-w64-mingw32- \
BINARY_PATH=/opt/mingw-sysroot/bin \
INCLUDE_PATH=/opt/mingw-sysroot/include \
LIBRARY_PATH=/opt/mingw-sysroot/lib \
SHARED_MODE=0 install && \
\
# x86_64 minizip
cd /tmp/zlib-${ZLIB_VERSION}/contrib/minizip && \
x86_64-w64-mingw32-gcc -c \
-I/opt/mingw-sysroot/include \
-DNOUNCRYPT -DNOCRYPT \
ioapi.c unzip.c zip.c && \
x86_64-w64-mingw32-ar rcs libminizip.a ioapi.o unzip.o zip.o && \
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/ && \
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 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 \
-DCMAKE_INSTALL_PREFIX=/opt/mingw-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-sysroot/include \
-DZLIB_LIBRARY=/opt/mingw-sysroot/lib/libz.a && \
cmake --build /tmp/libarchive-build && \
cmake --install /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 \
-O /usr/local/bin/linuxdeploy && \
chmod +x /usr/local/bin/linuxdeploy && \
wget -q https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage \
-O /usr/local/bin/linuxdeploy-plugin-qt && \
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
# ── appimagetool (for final AppImage creation) ──────────────────────────────
RUN wget -q https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage \
# ── appimagetool & static AppImage runtimes (x86_64 & aarch64) ─────────────────
# Note: Zeroing AppImage magic bytes 8-10 allows extraction under both native Linux and Rosetta 2
RUN mkdir -p /opt/appimage && \
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
rm /tmp/appimagetool && \
wget -q https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-x86_64 \
-O /opt/appimage/runtime-x86_64 && \
wget -q https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-aarch64 \
-O /opt/appimage/runtime-aarch64 && \
chmod +x /opt/appimage/runtime-x86_64 /opt/appimage/runtime-aarch64
# ── gitlab-runner (shell executor) ───────────────────────────────────────────
# ── 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 && \
chmod +x /usr/local/bin/gitlab-runner && \
+41 -21
View File
@@ -1,35 +1,55 @@
#!/bin/bash
# Package Linux build as AppImage
# Usage: package-linux.sh <build-dir> <qt-dir> <output-dir>
#!/usr/bin/env bash
# Package a built Linux binary into an AppImage (supports x86_64 and arm64).
#
# Usage:
# packaging/package-linux.sh <build-dir> <qt-dir> <output-dir> [arch]
#
# Example:
# packaging/package-linux.sh build-linux /opt/qt/6.12.0/gcc_64 dist x86_64
# packaging/package-linux.sh build-linux-arm64 /opt/qt/6.12.0/gcc_arm64 dist arm64
set -euo pipefail
BUILD_DIR="${1:?Usage: package-linux.sh <build-dir> <qt-dir> <output-dir>}"
BUILD_DIR="${1:?Usage: package-linux.sh <build-dir> <qt-dir> <output-dir> [arch]}"
QT_DIR="${2:?}"
OUTPUT_DIR="${3:?}"
ARCH="${4:-x86_64}"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
APPDIR="${BUILD_DIR}/AppDir"
BUILD_DIR="$(cd "$BUILD_DIR" && pwd)"
QT_DIR="$(cd "$QT_DIR" && pwd)"
mkdir -p "$OUTPUT_DIR"
OUTPUT_DIR="$(cd "$OUTPUT_DIR" && pwd)"
if [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then
APPIMAGE_ARCH="aarch64"
OUTPUT_NAME="Asteria-arm64.AppImage"
else
APPIMAGE_ARCH="x86_64"
OUTPUT_NAME="Asteria-x86_64.AppImage"
fi
APPDIR="$BUILD_DIR/AppDir"
rm -rf "$APPDIR"
# linuxdeploy handles AppDir structure, library bundling, and AppRun
export QMAKE="$QT_DIR/bin/qmake"
export QML_SOURCES_PATHS="$PROJECT_DIR/src/qml"
export LD_LIBRARY_PATH="$QT_DIR/lib:${LD_LIBRARY_PATH:-}"
export OUTPUT="Asteria-x86_64.AppImage"
# ── Install via CMake into AppDir ────────────────────────────────────────────
cmake --install "$BUILD_DIR" --prefix "$APPDIR/usr"
linuxdeploy \
# ── Bundle Qt plugins, QML modules, and ELF libraries ────────────────────────
python3 "$PROJECT_DIR/scripts/bundle-linux-appdir.py" \
--appdir "$APPDIR" \
--executable "$BUILD_DIR/asteria-qt" \
--desktop-file "$PROJECT_DIR/packaging/asteria-qt.desktop" \
--icon-file "$PROJECT_DIR/packaging/icons/256x256/asteria-qt.png" \
--plugin qt \
--output appimage
--qt-dir "$QT_DIR" \
--arch "$ARCH"
mkdir -p "$OUTPUT_DIR"
SRC="$(pwd)/$OUTPUT"
DEST="$(cd "$OUTPUT_DIR" && pwd)/$OUTPUT"
if [ "$SRC" != "$DEST" ]; then
mv "$SRC" "$DEST"
# ── Generate AppImage with appimagetool ──────────────────────────────────────
RUNTIME_ARGS=()
if [ -f "/opt/appimage/runtime-${APPIMAGE_ARCH}" ]; then
RUNTIME_ARGS=(--runtime-file "/opt/appimage/runtime-${APPIMAGE_ARCH}")
fi
ARCH="$APPIMAGE_ARCH" appimagetool "${RUNTIME_ARGS[@]}" \
"$APPDIR" "$OUTPUT_DIR/$OUTPUT_NAME"
echo "==> AppImage ($ARCH) created: $OUTPUT_DIR/$OUTPUT_NAME ($(du -sh "$OUTPUT_DIR/$OUTPUT_NAME" | cut -f1))"
+77 -94
View File
@@ -1,119 +1,102 @@
#!/bin/bash
# Package Windows build as a portable directory with all DLLs
# Usage: package-windows.sh <build-dir> <qt-dir> <mingw-sysroot> <output-dir> [arch]
#!/usr/bin/env bash
# Package a cross-compiled Windows build into a portable folder / zip.
# Runs on Linux inside the CI Docker image (no windeployqt available).
#
# Usage:
# packaging/package-windows.sh <build-dir> <qt-windows-dir> <mingw-sysroot> <output-dir> [arch]
#
# Example:
# packaging/package-windows.sh build-windows /opt/qt/6.12.0/mingw_64 /opt/mingw-sysroot dist x86_64
# packaging/package-windows.sh build-windows-arm64 /opt/qt/6.12.0/mingw_arm64 /opt/mingw-arm64-sysroot dist arm64
set -euo pipefail
BUILD_DIR="${1:?Usage: package-windows.sh <build-dir> <qt-dir> <mingw-sysroot> <output-dir> [arch]}"
BUILD_DIR="${1:?Usage: package-windows.sh <build-dir> <qt-windows-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"
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
BUILD_DIR="$(cd "$BUILD_DIR" && pwd)"
QT_DIR="$(cd "$QT_DIR" && pwd)"
if [ -d "$MINGW_SYSROOT" ]; then
MINGW_SYSROOT="$(cd "$MINGW_SYSROOT" && pwd)"
fi
mkdir -p "$OUTPUT_DIR"
OUTPUT_DIR="$(cd "$OUTPUT_DIR" && pwd)"
if [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then
STAGE_NAME="asteria-qt-windows-arm64"
MINGW_TRIPLE="aarch64-w64-mingw32"
else
STAGE_NAME="asteria-qt-windows"
MINGW_TRIPLE="x86_64-w64-mingw32"
fi
DIST_DIR="$BUILD_DIR/dist"
rm -rf "$DIST_DIR"
mkdir -p "$DIST_DIR"
# Copy the main executable
# ── Main executable ──────────────────────────────────────────────────────────
cp "$BUILD_DIR/asteria-qt.exe" "$DIST_DIR/"
# Use windeployqt to gather Qt dependencies
# 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 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"
# ── Qt plugins ───────────────────────────────────────────────────────────────
if [ -d "$QT_DIR/share/qt6/plugins" ]; then
QT_PLUGINS_SRC="$QT_DIR/share/qt6/plugins"
else
QT_PLUGINS_SRC="$QT_DIR/plugins"
fi
mkdir -p "$DIST_DIR/platforms"
cp "$PLUGIN_DIR/platforms/qwindows.dll" "$DIST_DIR/platforms/" 2>/dev/null || true
mkdir -p "$DIST_DIR/imageformats"
cp "$PLUGIN_DIR/imageformats/"*.dll "$DIST_DIR/imageformats/" 2>/dev/null || true
mkdir -p "$DIST_DIR/iconengines"
cp "$PLUGIN_DIR/iconengines/"*.dll "$DIST_DIR/iconengines/" 2>/dev/null || true
mkdir -p "$DIST_DIR/tls"
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
mkdir -p "$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/"
for plugin_dir in platforms imageformats iconengines tls styles; do
if [ -d "$QT_PLUGINS_SRC/$plugin_dir" ]; then
mkdir -p "$DIST_DIR/$plugin_dir"
if [ "$plugin_dir" = "platforms" ]; then
cp "$QT_PLUGINS_SRC/platforms/qwindows.dll" "$DIST_DIR/platforms/"
else
cp "$QT_PLUGINS_SRC/$plugin_dir/"*.dll "$DIST_DIR/$plugin_dir/" 2>/dev/null || true
fi
fi
done
# Architecture-specific runtime DLLs
if [ "$ARCH" = "arm64" ] || [ "$ARCH" = "aarch64" ]; then
PKG_NAME="asteria-qt-windows-arm64"
# LLVM-MinGW runtime DLLs for ARM64
ARM64_DLLS=(
libc++.dll
libunwind.dll
libwinpthread-1.dll
)
for dll in "${ARM64_DLLS[@]}"; do
if [ ! -f "$DIST_DIR/$dll" ]; then
find /opt/llvm-mingw/aarch64-w64-mingw32/ -name "$dll" -exec cp {} "$DIST_DIR/" \; 2>/dev/null || true
fi
if [ ! -f "$DIST_DIR/$dll" ] && [ -f "$MINGW_SYSROOT/bin/$dll" ]; then
cp "$MINGW_SYSROOT/bin/$dll" "$DIST_DIR/"
fi
done
# ── QML modules ──────────────────────────────────────────────────────────────
if [ -d "$QT_DIR/share/qt6/qml" ]; then
QT_QML_SRC="$QT_DIR/share/qt6/qml"
else
PKG_NAME="asteria-qt-windows"
QT_QML_SRC="$QT_DIR/qml"
fi
# 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/"
mkdir -p "$DIST_DIR/qml"
for mod in QtCore Qt QtQuick QtQml; do
if [ -d "$QT_QML_SRC/$mod" ]; then
cp -r "$QT_QML_SRC/$mod" "$DIST_DIR/qml/"
fi
done
fi
done
# 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
cp "$MINGW_SYSROOT/bin/libuchardet.dll" "$DIST_DIR/"
fi
# Prune unused heavy QML subdirectories so unneeded DLLs are not pulled in
for unused_qml in tooling LocalStorage Particles Pdf Scene2D Scene3D Timeline VirtualKeyboard; do
rm -rf "$DIST_DIR/qml/QtQuick/$unused_qml"
done
# Create qt.conf for portable deployment
cat > "$DIST_DIR/qt.conf" << 'EOF'
[Paths]
Plugins = .
Qml2Imports = qml
EOF
# ── Bundle transitive runtime DLLs & verify all PE imports ───────────────────
echo "==> Bundling and verifying DLL dependencies in $DIST_DIR..."
python3 "$PROJECT_DIR/scripts/verify-windows-dlls.py" "$DIST_DIR" \
--bundle-from \
"$QT_DIR/bin" \
"$MINGW_SYSROOT/bin" \
"/opt/llvm-mingw/$MINGW_TRIPLE/bin" \
"/usr/lib/gcc/$MINGW_TRIPLE"/* \
"/usr/$MINGW_TRIPLE/lib" \
"/usr/$MINGW_TRIPLE/bin"
# Verify all PE binary dependencies in DIST_DIR
echo "==> Verifying bundled DLL dependencies in $DIST_DIR..."
python3 "$PROJECT_DIR/scripts/verify-windows-dlls.py" "$DIST_DIR"
# ── Clean up non-runtime files from QML dirs ─────────────────────────────────
find "$DIST_DIR/qml" -name '*.qmltypes' -o -name '*.metainfo' -o -name '*.prl' | xargs rm -f 2>/dev/null || true
# Output flat directory — GitLab zips the artifact directory on download
mkdir -p "$OUTPUT_DIR/$PKG_NAME"
cp -r "$DIST_DIR/"* "$OUTPUT_DIR/$PKG_NAME/"
# ── Copy to output directory ─────────────────────────────────────────────────
STAGE_DIR="$OUTPUT_DIR/$STAGE_NAME"
rm -rf "$STAGE_DIR"
cp -r "$DIST_DIR" "$STAGE_DIR"
echo "==> Windows ($ARCH) package created: $STAGE_DIR ($(du -sh "$STAGE_DIR" | cut -f1))"
+306
View File
@@ -0,0 +1,306 @@
#!/usr/bin/env python3
"""
Populates a Linux AppDir for asteria-qt (x86_64 or arm64/aarch64) by copying
required Qt plugins, QML modules, and transitive ELF shared libraries using
architecture-independent tools (readelf + patchelf).
Usage:
bundle-linux-appdir.py --appdir <AppDir> --qt-dir <QtDir> [--arch {x86_64,arm64}]
"""
import argparse
import os
import re
import shutil
import stat
import subprocess
import sys
# Standard AppImage host-provided system/driver libraries (excluded from AppDir/usr/lib)
EXCLUDED_SYSTEM_LIBS = {
"ld-linux-x86-64.so.2",
"ld-linux-aarch64.so.1",
"libanl.so.1",
"libc.so.6",
"libcrypt.so.1",
"libdbus-1.so.3",
"libdl.so.2",
"libdrm.so.2",
"libEGL.so.1",
"libexpat.so.1",
"libfontconfig.so.1",
"libfreetype.so.6",
"libgbm.so.1",
"libgcc_s.so.1",
"libGL.so.1",
"libGLdispatch.so.0",
"libglib-2.0.so.0",
"libGLX.so.0",
"libharfbuzz.so.0",
"libICE.so.6",
"libm.so.6",
"libnsl.so.1",
"libOpenGL.so.0",
"libpthread.so.0",
"libresolv.so.2",
"librt.so.1",
"libSM.so.6",
"libstdc++.so.6",
"libutil.so.1",
"libvulkan.so.1",
"libwayland-client.so.0",
"libwayland-cursor.so.0",
"libwayland-egl.so.1",
"libX11.so.6",
"libX11-xcb.so.1",
"libxcb.so.1",
"libXext.so.6",
"libz.so.1",
}
PLUGIN_DIRS = [
"platforms",
"wayland-decoration-client",
"wayland-graphics-integration-client",
"wayland-shell-integration",
"xcbglintegrations",
"platformthemes",
"platforminputcontexts",
"imageformats",
"iconengines",
"tls",
]
# Skip optional plugins that pull in heavy/unrelated desktop or embedded stacks
SKIP_PLUGINS = {
"libqeglfs.so",
"libqlinuxfb.so",
"libqvkkhrdisplay.so",
"libqvnc.so",
"libqgtk3.so",
"libqcertonlybackend.so",
}
QML_MODULES = [
"QtCore",
"Qt",
"QtQml",
"QtQuick",
]
UNUSED_QTQUICK_SUBDIRS = {
"tooling",
"LocalStorage",
"Particles",
"Pdf",
"Scene2D",
"Scene3D",
"Timeline",
"VirtualKeyboard",
}
NEEDED_RE = re.compile(r"\(NEEDED\)\s+Shared library:\s+\[([^\]]+)\]")
def is_elf(filepath):
if not os.path.isfile(filepath) or os.path.islink(filepath):
return False
try:
with open(filepath, "rb") as f:
return f.read(4) == b"\x7fELF"
except OSError:
return False
def get_dt_needed(filepath):
res = subprocess.run(["readelf", "-d", filepath], capture_output=True, text=True)
if res.returncode != 0:
return []
return NEEDED_RE.findall(res.stdout)
def setup_appdir_metadata(appdir):
desktop_src = os.path.join(appdir, "usr", "share", "applications", "asteria-qt.desktop")
icon_src = os.path.join(appdir, "usr", "share", "icons", "hicolor", "256x256", "apps", "asteria-qt.png")
if os.path.isfile(desktop_src):
shutil.copy2(desktop_src, os.path.join(appdir, "asteria-qt.desktop"))
if os.path.isfile(icon_src):
shutil.copy2(icon_src, os.path.join(appdir, "asteria-qt.png"))
dir_icon = os.path.join(appdir, ".DirIcon")
if os.path.lexists(dir_icon):
os.remove(dir_icon)
os.symlink("asteria-qt.png", dir_icon)
apprun_path = os.path.join(appdir, "AppRun")
with open(apprun_path, "w", encoding="utf-8") as f:
f.write(
"#!/bin/sh\n"
'HERE="$(dirname "$(readlink -f "$0")")"\n'
'export LD_LIBRARY_PATH="$HERE/usr/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"\n'
'export QT_PLUGIN_PATH="$HERE/usr/plugins"\n'
'export QML2_IMPORT_PATH="$HERE/usr/qml"\n'
'export QML_IMPORT_PATH="$HERE/usr/qml"\n'
'exec "$HERE/usr/bin/asteria-qt" "$@"\n'
)
os.chmod(apprun_path, 0o755)
qt_conf_path = os.path.join(appdir, "usr", "bin", "qt.conf")
with open(qt_conf_path, "w", encoding="utf-8") as f:
f.write("[Paths]\nPrefix = ..\nPlugins = plugins\nImports = qml\nQml2Imports = qml\n")
def copy_qt_plugins_and_qml(appdir, qt_dir):
plugins_src = os.path.join(qt_dir, "plugins")
plugins_dst = os.path.join(appdir, "usr", "plugins")
os.makedirs(plugins_dst, exist_ok=True)
for pdir in PLUGIN_DIRS:
src_sub = os.path.join(plugins_src, pdir)
if not os.path.isdir(src_sub):
continue
dst_sub = os.path.join(plugins_dst, pdir)
os.makedirs(dst_sub, exist_ok=True)
for fname in os.listdir(src_sub):
if not fname.endswith(".so") or fname in SKIP_PLUGINS:
continue
shutil.copy2(os.path.join(src_sub, fname), os.path.join(dst_sub, fname))
qml_src = os.path.join(qt_dir, "qml")
qml_dst = os.path.join(appdir, "usr", "qml")
os.makedirs(qml_dst, exist_ok=True)
for mod in QML_MODULES:
src_mod = os.path.join(qml_src, mod)
if os.path.isdir(src_mod):
dst_mod = os.path.join(qml_dst, mod)
if os.path.exists(dst_mod):
shutil.rmtree(dst_mod)
shutil.copytree(src_mod, dst_mod)
for unused in UNUSED_QTQUICK_SUBDIRS:
unused_path = os.path.join(qml_dst, "QtQuick", unused)
if os.path.isdir(unused_path):
shutil.rmtree(unused_path)
for root, _, files in os.walk(qml_dst):
for fname in files:
if fname.endswith((".qmltypes", ".metainfo", ".prl")):
os.remove(os.path.join(root, fname))
def find_library(soname, search_dirs):
for sdir in search_dirs:
candidate = os.path.join(sdir, soname)
if os.path.exists(candidate):
return os.path.realpath(candidate)
return None
def bundle_and_verify_libs(appdir, qt_dir, triplet):
lib_dst = os.path.join(appdir, "usr", "lib")
os.makedirs(lib_dst, exist_ok=True)
search_dirs = [
os.path.join(qt_dir, "lib"),
f"/usr/lib/{triplet}",
f"/lib/{triplet}",
]
# Remove optional plugins (like imageformats/tls) whose third-party backing lib isn't installed
plugins_dst = os.path.join(appdir, "usr", "plugins")
for root, _, files in os.walk(plugins_dst):
for fname in list(files):
fpath = os.path.join(root, fname)
if not is_elf(fpath):
continue
needed = get_dt_needed(fpath)
missing_opt = [
n
for n in needed
if n not in EXCLUDED_SYSTEM_LIBS and find_library(n, search_dirs) is None
]
if missing_opt and os.path.basename(root) in ("imageformats", "tls", "platforminputcontexts", "wayland-graphics-integration-client"):
print(f" Skipping optional plugin {fname} (missing optional system lib: {', '.join(missing_opt)})")
os.remove(fpath)
# Collect initial ELF files in AppDir
queue = []
for root, _, files in os.walk(appdir):
for fname in files:
fpath = os.path.join(root, fname)
if is_elf(fpath):
queue.append(fpath)
bundled_sonames = set(os.listdir(lib_dst))
copied_count = 0
while queue:
elf_path = queue.pop(0)
for soname in get_dt_needed(elf_path):
if soname in EXCLUDED_SYSTEM_LIBS or soname in bundled_sonames:
continue
real_src = find_library(soname, search_dirs)
if real_src is None:
continue
dst_file = os.path.join(lib_dst, soname)
shutil.copy2(real_src, dst_file)
os.chmod(dst_file, stat.S_IMODE(os.stat(dst_file).st_mode) | stat.S_IWUSR)
bundled_sonames.add(soname)
queue.append(dst_file)
copied_count += 1
print(f"==> Bundled {copied_count} shared libraries into {lib_dst}")
# Patch RPATH so executable and libraries resolve $ORIGIN
exe_path = os.path.join(appdir, "usr", "bin", "asteria-qt")
subprocess.run(["patchelf", "--set-rpath", "$ORIGIN/../lib", exe_path], check=True)
for fname in os.listdir(lib_dst):
fpath = os.path.join(lib_dst, fname)
if is_elf(fpath):
subprocess.run(["patchelf", "--set-rpath", "$ORIGIN", fpath], check=False)
# Verify all DT_NEEDED dependencies in AppDir
missing_by_soname = {}
all_elfs = []
for root, _, files in os.walk(appdir):
for fname in files:
fpath = os.path.join(root, fname)
if is_elf(fpath):
all_elfs.append(fpath)
for elf_path in sorted(all_elfs):
rel = os.path.relpath(elf_path, appdir)
for soname in get_dt_needed(elf_path):
if soname in EXCLUDED_SYSTEM_LIBS or soname in bundled_sonames:
continue
missing_by_soname.setdefault(soname, []).append(rel)
if missing_by_soname:
print(f"FAILED: Found {len(missing_by_soname)} missing ELF shared libraries in {appdir}:", file=sys.stderr)
for soname, importers in sorted(missing_by_soname.items()):
print(f" [MISSING] {soname} needed by:", file=sys.stderr)
for imp in importers[:5]:
print(f" - {imp}", file=sys.stderr)
sys.exit(1)
print(f"==> ELF verification passed: scanned {len(all_elfs)} binaries in {appdir}, 0 missing dependencies.")
def main():
parser = argparse.ArgumentParser(description="Bundle Qt plugins, QML modules, and ELF libraries into AppDir")
parser.add_argument("--appdir", required=True, help="Path to AppDir")
parser.add_argument("--qt-dir", required=True, help="Path to target Qt installation directory")
parser.add_argument("--arch", default="x86_64", choices=["x86_64", "arm64", "aarch64"])
args = parser.parse_args()
triplet = "aarch64-linux-gnu" if args.arch in ("arm64", "aarch64") else "x86_64-linux-gnu"
setup_appdir_metadata(args.appdir)
copy_qt_plugins_and_qml(args.appdir, args.qt_dir)
bundle_and_verify_libs(args.appdir, args.qt_dir, triplet)
if __name__ == "__main__":
main()
+130 -49
View File
@@ -1,32 +1,51 @@
#!/usr/bin/env python3
"""
Downloads and extracts MSYS2 clangarm64 Qt6 packages and all transitive
runtime dependencies into the destination directory.
Downloads and extracts MSYS2 MinGW-w64 (clang64 / clangarm64) Qt6 packages,
third-party libraries (libarchive, libiconv, minizip, uchardet, zlib), and all
transitive runtime dependencies into the destination sysroot directory.
Usage:
download-mingw-arm64-qt.py --dest /path/to/qt_arm64 [--dry-run]
download-mingw-arm64-qt.py --dest /path/to/sysroot [--arch {x86_64,arm64}] [--dry-run]
"""
import argparse
import glob
import io
import os
import re
import shutil
import subprocess
import sys
import tarfile
import urllib.error
import urllib.request
MIRROR_URLS = [
"https://mirror.msys2.org/mingw/clangarm64",
"https://repo.msys2.org/mingw/clangarm64",
ARCH_CONFIG = {
"x86_64": {
"repo": "clang64",
"pkg_prefix": "mingw-w64-clang-x86_64",
},
"arm64": {
"repo": "clangarm64",
"pkg_prefix": "mingw-w64-clang-aarch64",
},
}
MIRROR_BASES = [
"https://mirror.msys2.org/mingw",
"https://repo.msys2.org/mingw",
]
SEEDS = [
"mingw-w64-clang-aarch64-qt6-base",
"mingw-w64-clang-aarch64-qt6-declarative",
"mingw-w64-clang-aarch64-qt6-svg",
"mingw-w64-clang-aarch64-qt6-5compat",
SEED_PACKAGES = [
"qt6-base",
"qt6-declarative",
"qt6-svg",
"qt6-imageformats",
"libarchive",
"libiconv",
"minizip",
"uchardet",
"zlib",
]
# Non-runtime / scripting packages not required by Qt6 C++ / QML applications
@@ -42,6 +61,13 @@ EXPECTED_DLLS = [
"Qt6Gui.dll",
"Qt6Qml.dll",
"Qt6Quick.dll",
"Qt6Svg.dll",
"Qt6Widgets.dll",
"Qt6Network.dll",
"libarchive-13.dll",
"libiconv-2.dll",
"libminizip-1.dll",
"libuchardet.dll",
"zlib1.dll",
"libzstd.dll",
"libmd4c.dll",
@@ -50,30 +76,37 @@ EXPECTED_DLLS = [
"libharfbuzz-0.dll",
"libpng16-16.dll",
"libglib-2.0-0.dll",
"libc++.dll",
"libunwind.dll",
]
EXPECTED_PC_FILES = [
"minizip.pc",
"libarchive.pc",
"uchardet.pc",
]
def fetch_url(url, timeout=30):
def fetch_url(url, timeout=60):
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0 (Asteria-CI)"})
with urllib.request.urlopen(req, timeout=timeout) as resp:
return resp.read()
def download_db():
for mirror in MIRROR_URLS:
db_url = f"{mirror}/clangarm64.db.tar.zst"
def download_db(repo):
for base in MIRROR_BASES:
db_url = f"{base}/{repo}/{repo}.db.tar.zst"
print(f"==> Downloading package database from {db_url}...")
try:
data = fetch_url(db_url, timeout=30)
print(f"==> Downloaded database ({len(data)} bytes)")
return data, mirror
return data, f"{base}/{repo}"
except Exception as e:
print(f" Failed ({e}), trying next mirror...", file=sys.stderr)
raise RuntimeError("Failed to download clangarm64.db.tar.zst from all mirrors")
raise RuntimeError(f"Failed to download {repo}.db.tar.zst from all mirrors")
def parse_database(db_bytes):
# Decompress zstd
res = subprocess.run(["zstd", "-d", "-c"], input=db_bytes, capture_output=True)
if res.returncode != 0:
raise RuntimeError(f"zstd decompression failed: {res.stderr.decode('utf-8', errors='replace')}")
@@ -84,14 +117,13 @@ def parse_database(db_bytes):
for member in tar.getmembers():
if member.isfile() and member.name.endswith("/desc"):
f = tar.extractfile(member)
if not f:
continue
content = f.read().decode("utf-8", errors="replace")
content = tar.extractfile(member).read().decode("utf-8", errors="replace")
current_section = None
pkg_name = None
filename = None
depends = []
current_section = None
provides = []
for line in content.splitlines():
line = line.strip()
if line.startswith("%") and line.endswith("%"):
@@ -105,18 +137,22 @@ def parse_database(db_bytes):
depends.append(dep)
elif current_section == "PROVIDES" and line:
prov = re.split(r"[<>=]", line)[0]
provides_map[prov] = pkg_name
provides.append(prov)
if pkg_name:
packages[pkg_name] = {"filename": filename, "depends": depends}
provides_map[pkg_name] = pkg_name
for prov in provides:
if prov not in packages:
provides_map[prov] = pkg_name
return packages, provides_map
def resolve_dependencies(packages, provides_map):
queue = list(SEEDS)
visited = set(SEEDS)
def resolve_dependencies(packages, provides_map, pkg_prefix):
seeds = [f"{pkg_prefix}-{name}" for name in SEED_PACKAGES]
queue = list(seeds)
visited = set(seeds)
resolved = []
while queue:
@@ -140,17 +176,17 @@ def resolve_dependencies(packages, provides_map):
return sorted(resolved)
def download_and_extract_packages(resolved, base_mirror, dest_dir):
def download_and_extract_packages(resolved, repo, dest_dir):
os.makedirs(dest_dir, exist_ok=True)
temp_pkg = "/tmp/arm64_pkg.tar.zst"
temp_pkg = f"/tmp/msys2_{repo}_pkg.tar.zst"
for i, (pkg_name, filename) in enumerate(resolved, 1):
print(f"[{i}/{len(resolved)}] Downloading {filename}...")
downloaded = False
last_err = None
for mirror in MIRROR_URLS:
pkg_url = f"{mirror}/{filename}"
for base in MIRROR_BASES:
pkg_url = f"{base}/{repo}/{filename}"
try:
data = fetch_url(pkg_url, timeout=60)
with open(temp_pkg, "wb") as f:
@@ -159,12 +195,11 @@ def download_and_extract_packages(resolved, base_mirror, dest_dir):
break
except Exception as e:
last_err = e
print(f" Failed from {mirror} ({e}), trying next mirror...", file=sys.stderr)
print(f" Failed from {base}/{repo} ({e}), trying next mirror...", file=sys.stderr)
if not downloaded:
raise RuntimeError(f"Failed to download {filename}: {last_err}")
# Extract stripping top-level directory (clangarm64)
tar_res = subprocess.run(
["tar", "-I", "zstd", "-xf", temp_pkg, "--strip-components=1", "-C", dest_dir],
capture_output=True,
@@ -177,35 +212,80 @@ def download_and_extract_packages(resolved, base_mirror, dest_dir):
raise RuntimeError(f"Failed to extract {filename}: {err}")
def configure_sysroot(dest_dir, repo):
abs_dest = os.path.abspath(dest_dir)
# Rewrite hardcoded /clang64 or /clangarm64 prefixes in pkg-config files
pc_files = glob.glob(os.path.join(abs_dest, "lib", "pkgconfig", "*.pc")) + glob.glob(
os.path.join(abs_dest, "share", "pkgconfig", "*.pc")
)
for pc_path in pc_files:
with open(pc_path, "r", encoding="utf-8", errors="replace") as f:
content = f.read()
updated = content.replace(f"/{repo}", abs_dest)
if updated != content:
with open(pc_path, "w", encoding="utf-8") as f:
f.write(updated)
# Copy any share/pkgconfig/*.pc (e.g. zlib.pc) into lib/pkgconfig so a single PKG_CONFIG_PATH works
lib_pc_dir = os.path.join(abs_dest, "lib", "pkgconfig")
os.makedirs(lib_pc_dir, exist_ok=True)
for pc_path in glob.glob(os.path.join(abs_dest, "share", "pkgconfig", "*.pc")):
target_pc = os.path.join(lib_pc_dir, os.path.basename(pc_path))
if not os.path.exists(target_pc):
shutil.copy2(pc_path, target_pc)
# Remove target Windows Qt6*Tools CMake packages so CMake cross-compilation
# always uses host Linux tools (moc, rcc, qmlcachegen, qmlimportscanner) from QT_HOST_PATH.
for tools_dir in glob.glob(os.path.join(abs_dest, "lib", "cmake", "Qt6*Tools")):
if os.path.isdir(tools_dir):
shutil.rmtree(tools_dir)
def verify_installation(dest_dir):
bin_dir = os.path.join(dest_dir, "bin")
if not os.path.isdir(bin_dir):
raise RuntimeError(f"Expected bin directory missing: {bin_dir}")
missing = []
for dll in EXPECTED_DLLS:
dll_path = os.path.join(bin_dir, dll)
if not os.path.isfile(dll_path):
missing.append(dll)
missing_dlls = [dll for dll in EXPECTED_DLLS if not os.path.isfile(os.path.join(bin_dir, dll))]
if missing_dlls:
raise RuntimeError(f"Missing expected DLLs in {bin_dir}: {', '.join(missing_dlls)}")
if missing:
raise RuntimeError(f"Missing expected DLLs in {bin_dir}: {', '.join(missing)}")
pc_dir = os.path.join(dest_dir, "lib", "pkgconfig")
missing_pcs = [pc for pc in EXPECTED_PC_FILES if not os.path.isfile(os.path.join(pc_dir, pc))]
if missing_pcs:
raise RuntimeError(f"Missing expected pkg-config files in {pc_dir}: {', '.join(missing_pcs)}")
print(f"==> Verification passed: all {len(EXPECTED_DLLS)} required core DLLs present in {bin_dir}")
print(
f"==> Verification passed: all {len(EXPECTED_DLLS)} core DLLs and "
f"{len(EXPECTED_PC_FILES)} pkg-config files present in {dest_dir}"
)
def main():
parser = argparse.ArgumentParser(description="Download MSYS2 clangarm64 Qt6 packages and dependencies")
parser = argparse.ArgumentParser(
description="Download MSYS2 Windows (x86_64 / arm64) Qt6 and third-party packages"
)
parser.add_argument("--dest", required=True, help="Destination directory to extract packages into")
parser.add_argument(
"--arch",
choices=["x86_64", "arm64"],
default="arm64",
help="Target Windows architecture (default: arm64)",
)
parser.add_argument("--dry-run", action="store_true", help="Resolve packages without downloading or extracting")
args = parser.parse_args()
db_bytes, mirror = download_db()
packages, provides_map = parse_database(db_bytes)
print(f"==> Parsed {len(packages)} packages from MSYS2 database")
cfg = ARCH_CONFIG[args.arch]
repo = cfg["repo"]
pkg_prefix = cfg["pkg_prefix"]
resolved = resolve_dependencies(packages, provides_map)
print(f"==> Resolved {len(resolved)} packages to install:")
db_bytes, _ = download_db(repo)
packages, provides_map = parse_database(db_bytes)
print(f"==> Parsed {len(packages)} packages from MSYS2 {repo} database")
resolved = resolve_dependencies(packages, provides_map, pkg_prefix)
print(f"==> Resolved {len(resolved)} packages to install for Windows {args.arch} ({repo}):")
for pkg_name, filename in resolved:
print(f" - {pkg_name} ({filename})")
@@ -213,9 +293,10 @@ def main():
print("==> Dry run complete.")
return
download_and_extract_packages(resolved, mirror, args.dest)
download_and_extract_packages(resolved, repo, args.dest)
configure_sysroot(args.dest, repo)
verify_installation(args.dest)
print(f"==> Successfully installed Qt6 Windows ARM64 into {args.dest}")
print(f"==> Successfully installed Windows {args.arch} sysroot into {args.dest}")
if __name__ == "__main__":
+5 -5
View File
@@ -9,7 +9,7 @@ brew update
brew install cmake ninja pkg-config uchardet minizip libarchive gitlab-runner
echo ""
echo "Installing Qt 6.10.3 via aqtinstall → /opt/qt ..."
echo "Installing Qt 6.12.0 via aqtinstall → /opt/qt ..."
python3 -m venv /tmp/aqt-venv
/tmp/aqt-venv/bin/pip install --quiet aqtinstall
@@ -19,17 +19,17 @@ QT_DIR_NAME="macos"
sudo mkdir -p /opt/qt
sudo chown "$USER" /opt/qt
/tmp/aqt-venv/bin/aqt install-qt mac desktop 6.10.3 "$QT_ARCH" \
/tmp/aqt-venv/bin/aqt install-qt mac desktop 6.12.0 "$QT_ARCH" \
-m qtimageformats qtpdf --outputdir /opt/qt
/tmp/aqt-venv/bin/aqt install-src mac 6.10.3 --outputdir /opt/qt
/tmp/aqt-venv/bin/aqt install-src mac 6.12.0 --outputdir /opt/qt
rm -rf /tmp/aqt-venv
QT_DIR="/opt/qt/6.10.3/$QT_DIR_NAME"
QT_DIR="/opt/qt/6.12.0/$QT_DIR_NAME"
echo ""
echo "All dependencies installed."
echo ""
echo "Qt 6.10.3 is at $QT_DIR"
echo "Qt 6.12.0 is at $QT_DIR"
echo ""
echo "Build with:"
echo " PKG_CONFIG_PATH=\"\$(brew --prefix libarchive)/lib/pkgconfig:\$PKG_CONFIG_PATH\" \\"
+178 -26
View File
@@ -1,41 +1,193 @@
#!/usr/bin/env bash
# Install all development dependencies for asteria-qt on Ubuntu/Debian.
# Tested on Ubuntu 24.04. Run with sudo or as root.
# Qt 6.10.x is installed via aqtinstall to /opt/qt — the Ubuntu apt repo only
# ships Qt 6.4, which is too old (qt_policy QTP0004 requires Qt 6.8+).
# Install development dependencies for asteria-qt on Ubuntu (24.04+).
# Run with sudo or as root.
#
# Usage:
# sudo scripts/install-deps-ubuntu.sh [--with-arm64] [--with-sources]
#
# Environment variables:
# QT_VERSION Qt version to install via aqtinstall (default: 6.12.0)
# QT_INSTALL_DIR Destination directory for Qt (default: /opt/qt)
set -euo pipefail
apt-get update
QT_VERSION="${QT_VERSION:-6.12.0}"
QT_INSTALL_DIR="${QT_INSTALL_DIR:-/opt/qt}"
WITH_ARM64=false
WITH_SOURCES=false
apt-get install -y \
build-essential \
cmake \
ninja-build \
git \
libgl1-mesa-dev \
libxkbcommon-dev \
libuchardet-dev \
zlib1g-dev \
libminizip-dev \
libarchive-dev \
libdjvulibre-dev \
libwpd-dev \
for arg in "$@"; do
case "$arg" in
--with-arm64) WITH_ARM64=true ;;
--with-sources) WITH_SOURCES=true ;;
*)
echo "Unknown option: $arg" >&2
echo "Usage: $0 [--with-arm64] [--with-sources]" >&2
exit 1
;;
esac
done
export DEBIAN_FRONTEND=noninteractive
HOST_ARCH="$(dpkg --print-architecture)"
if [ "$WITH_ARM64" = true ] && [ "$HOST_ARCH" = "amd64" ]; then
echo "==> Enabling Ubuntu arm64 multiarch repository..."
dpkg --add-architecture arm64
if [ -f /etc/apt/sources.list.d/ubuntu.sources ]; then
if ! grep -q "^Architectures:" /etc/apt/sources.list.d/ubuntu.sources; then
sed -i "s/^Types: deb$/Types: deb\nArchitectures: amd64/" /etc/apt/sources.list.d/ubuntu.sources
fi
SUITE="$(awk '/^Suites:/ {print $2; exit}' /etc/apt/sources.list.d/ubuntu.sources)"
SUITE="${SUITE:-noble}"
cat <<EOF > /etc/apt/sources.list.d/ubuntu-arm64.sources
Types: deb
URIs: http://ports.ubuntu.com/ubuntu-ports/
Suites: ${SUITE} ${SUITE}-updates ${SUITE}-backports ${SUITE}-security
Components: main universe restricted multiverse
Architectures: arm64
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
EOF
fi
fi
echo "==> Installing system build tools and libraries..."
apt-get update -qq
PACKAGES=(
build-essential
ca-certificates
cmake
curl
file
git
jq
libarchive-dev
libdbus-1-dev
libegl-dev
libfontconfig1-dev
libfreetype-dev
libgl-dev
libglib2.0-0t64
libminizip-dev
libtiff6
libuchardet-dev
libwayland-client0
libwayland-cursor0
libwayland-egl1
libwebp7
libwebpdemux2
libwebpmux3
libxcb-cursor0
libxcb-icccm4
libxcb-image0
libxcb-keysyms1
libxcb-randr0
libxcb-render-util0
libxcb-shape0
libxcb-shm0
libxcb-sync1
libxcb-util1
libxcb-xfixes0
libxcb-xkb1
libxkbcommon-dev
libxkbcommon-x11-0
ninja-build
patchelf
pkg-config
python3
python3-venv
wget
xz-utils
zip
zlib1g-dev
zstd
)
echo ""
echo "Installing Qt 6.10.3 via aqtinstall → /opt/qt ..."
if [ "$WITH_ARM64" = true ] && [ "$HOST_ARCH" = "amd64" ]; then
PACKAGES+=(
g++-aarch64-linux-gnu
libarchive13t64:arm64
libdbus-1-dev:arm64
libegl-dev:arm64
libfontconfig1-dev:arm64
libfreetype-dev:arm64
libgl-dev:arm64
libglib2.0-0t64:arm64
libminizip-dev:arm64
libtiff6:arm64
libuchardet-dev:arm64
libwayland-client0:arm64
libwayland-cursor0:arm64
libwayland-egl1:arm64
libwebp7:arm64
libwebpdemux2:arm64
libwebpmux3:arm64
libxcb-cursor0:arm64
libxcb-icccm4:arm64
libxcb-image0:arm64
libxcb-keysyms1:arm64
libxcb-randr0:arm64
libxcb-render-util0:arm64
libxcb-shape0:arm64
libxcb-shm0:arm64
libxcb-sync1:arm64
libxcb-util1:arm64
libxcb-xfixes0:arm64
libxcb-xkb1:arm64
libxkbcommon-dev:arm64
libxkbcommon-x11-0:arm64
zlib1g-dev:arm64
)
fi
apt-get install -y --no-install-recommends "${PACKAGES[@]}"
if [ "$WITH_ARM64" = true ] && [ "$HOST_ARCH" = "amd64" ]; then
# libarchive-dev is not Multi-Arch: same on Ubuntu 24.04 (due to libext2fs-dev);
# headers are already in /usr/include, so wire the arm64 .so symlink and .pc file.
ln -sf libarchive.so.13 /usr/lib/aarch64-linux-gnu/libarchive.so
mkdir -p /usr/lib/aarch64-linux-gnu/pkgconfig
sed 's/x86_64-linux-gnu/aarch64-linux-gnu/g' \
/usr/lib/x86_64-linux-gnu/pkgconfig/libarchive.pc \
> /usr/lib/aarch64-linux-gnu/pkgconfig/libarchive.pc
fi
echo "==> Installing Qt ${QT_VERSION} via aqtinstall -> ${QT_INSTALL_DIR}..."
python3 -m venv /tmp/aqt-venv
/tmp/aqt-venv/bin/pip install --quiet aqtinstall
/tmp/aqt-venv/bin/aqt install-qt linux desktop 6.10.3 linux_gcc_64 -m qtimageformats qtpdf qtwebview --outputdir /opt/qt
/tmp/aqt-venv/bin/aqt install-src linux 6.10.3 --archives qtbase qtimageformats qtwebview --outputdir /opt/qt
if [ "$HOST_ARCH" = "arm64" ]; then
/tmp/aqt-venv/bin/aqt install-qt linux_arm64 desktop "${QT_VERSION}" linux_gcc_arm64 \
-m qtimageformats --outputdir "${QT_INSTALL_DIR}"
QT_NATIVE_DIR="${QT_INSTALL_DIR}/${QT_VERSION}/gcc_arm64"
else
/tmp/aqt-venv/bin/aqt install-qt linux desktop "${QT_VERSION}" linux_gcc_64 \
-m qtimageformats --outputdir "${QT_INSTALL_DIR}"
QT_NATIVE_DIR="${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64"
if [ "$WITH_ARM64" = true ]; then
echo "==> Installing Qt ${QT_VERSION} (Linux arm64) via aqtinstall -> ${QT_INSTALL_DIR}..."
/tmp/aqt-venv/bin/aqt install-qt linux_arm64 desktop "${QT_VERSION}" linux_gcc_arm64 \
-m qtimageformats --outputdir "${QT_INSTALL_DIR}"
fi
fi
if [ "$WITH_SOURCES" = true ]; then
/tmp/aqt-venv/bin/aqt install-src linux "${QT_VERSION}" \
--archives qtbase qtdeclarative qtsvg qtimageformats --outputdir "${QT_INSTALL_DIR}"
fi
rm -rf /tmp/aqt-venv
echo ""
echo "All dependencies installed."
echo ""
echo "Qt 6.10.3 is at /opt/qt/6.10.3/gcc_64"
echo "==> All Ubuntu dependencies installed."
echo " Qt ${QT_VERSION} native path: ${QT_NATIVE_DIR}"
if [ "$WITH_ARM64" = true ] && [ "$HOST_ARCH" = "amd64" ]; then
echo " Qt ${QT_VERSION} arm64 path: ${QT_INSTALL_DIR}/${QT_VERSION}/gcc_arm64"
fi
echo ""
echo "Build with:"
echo " cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=/opt/qt/6.10.3/gcc_64"
echo " cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=${QT_NATIVE_DIR}"
echo " cmake --build build --parallel"
+4 -4
View File
@@ -24,19 +24,19 @@ pacman -S --needed \
mingw-w64-x86_64-python-psutil
echo ""
echo "Installing Qt 6.10.3 via aqtinstall → /opt/qt ..."
echo "Installing Qt 6.12.0 via aqtinstall → /opt/qt ..."
python3 -m venv --system-site-packages /tmp/aqt-venv
/tmp/aqt-venv/bin/python3 -m pip install --upgrade pip
/tmp/aqt-venv/bin/python3 -m pip install setuptools pyppmd
/tmp/aqt-venv/bin/pip install aqtinstall
/tmp/aqt-venv/bin/aqt install-qt windows desktop 6.10.3 win64_mingw -m qtimageformats qtpdf qtwebview --outputdir /opt/qt
/tmp/aqt-venv/bin/aqt install-qt windows desktop 6.12.0 win64_mingw -m qtimageformats qtpdf qtwebview --outputdir /opt/qt
rm -rf /tmp/aqt-venv
echo ""
echo "All dependencies installed."
echo ""
echo "Qt 6.10.3 is at /opt/qt/6.10.3/mingw_64"
echo "Qt 6.12.0 is at /opt/qt/6.12.0/mingw_64"
echo ""
echo "Build with:"
echo " cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=c:\msys64\opt\qt\6.10.3\mingw_64"
echo " cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_PREFIX_PATH=c:\msys64\opt\qt\6.12.0\mingw_64"
echo " cmake --build build --parallel"
+27
View File
@@ -0,0 +1,27 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER aarch64-linux-gnu-g++)
set(CMAKE_EXE_LINKER_FLAGS_INIT "-Wl,-rpath-link,/usr/lib/aarch64-linux-gnu -Wl,-rpath-link,/lib/aarch64-linux-gnu")
set(CMAKE_SHARED_LINKER_FLAGS_INIT "-Wl,-rpath-link,/usr/lib/aarch64-linux-gnu -Wl,-rpath-link,/lib/aarch64-linux-gnu")
list(APPEND CMAKE_FIND_ROOT_PATH
${CMAKE_PREFIX_PATH}
/usr/aarch64-linux-gnu
/usr/lib/aarch64-linux-gnu
/usr
)
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)
set(QT_NO_PACKAGE_VERSION_CHECK TRUE)
set(QT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING TRUE)
# Point pkg-config at the Ubuntu arm64 multiarch pkgconfig directories
set(ENV{PKG_CONFIG_LIBDIR} "/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig")
set(ENV{PKG_CONFIG_PATH} "")
+13 -6
View File
@@ -6,15 +6,22 @@ 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)
# -DCMAKE_FIND_ROOT_PATH on the cmake command line (e.g. the Qt Windows ARM64 install dir).
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_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} "")
set(QT_NO_PACKAGE_VERSION_CHECK TRUE)
set(QT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING TRUE)
# Point pkg-config at the MinGW ARM64 sysroot so it never picks up host Linux .pc files
if(DEFINED ENV{MINGW_ARM64_SYSROOT} AND NOT "$ENV{MINGW_ARM64_SYSROOT}" STREQUAL "")
set(ENV{PKG_CONFIG_LIBDIR} "$ENV{MINGW_ARM64_SYSROOT}/lib/pkgconfig:$ENV{MINGW_ARM64_SYSROOT}/share/pkgconfig")
elseif(DEFINED ENV{QT_WINDOWS_ARM64_DIR} AND NOT "$ENV{QT_WINDOWS_ARM64_DIR}" STREQUAL "")
set(ENV{PKG_CONFIG_LIBDIR} "$ENV{QT_WINDOWS_ARM64_DIR}/lib/pkgconfig:$ENV{QT_WINDOWS_ARM64_DIR}/share/pkgconfig")
else()
set(ENV{PKG_CONFIG_LIBDIR} "/opt/mingw-arm64-sysroot/lib/pkgconfig:/opt/mingw-arm64-sysroot/share/pkgconfig")
endif()
+16 -16
View File
@@ -1,27 +1,27 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR x86_64)
# 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()
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)
# 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),
# while plain set() would silently override them and break find_package(Qt6).
list(APPEND CMAKE_FIND_ROOT_PATH /opt/mingw-sysroot /usr/x86_64-w64-mingw32)
# -DCMAKE_FIND_ROOT_PATH on the cmake command line (e.g. the Qt Windows install dir).
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH} /opt/mingw-sysroot /opt/llvm-mingw/x86_64-w64-mingw32 /usr/x86_64-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 sysroot so it finds cross-compiled .pc files
set(ENV{PKG_CONFIG_LIBDIR} "$ENV{MINGW_SYSROOT}/lib/pkgconfig")
set(ENV{PKG_CONFIG_PATH} "")
set(QT_NO_PACKAGE_VERSION_CHECK TRUE)
set(QT_NO_PACKAGE_VERSION_INCOMPATIBLE_WARNING TRUE)
# Point pkg-config at the MinGW x86_64 sysroot so it never picks up host Linux .pc files
if(DEFINED ENV{MINGW_SYSROOT} AND NOT "$ENV{MINGW_SYSROOT}" STREQUAL "")
set(ENV{PKG_CONFIG_LIBDIR} "$ENV{MINGW_SYSROOT}/lib/pkgconfig:$ENV{MINGW_SYSROOT}/share/pkgconfig")
elseif(DEFINED ENV{QT_WINDOWS_DIR} AND NOT "$ENV{QT_WINDOWS_DIR}" STREQUAL "")
set(ENV{PKG_CONFIG_LIBDIR} "$ENV{QT_WINDOWS_DIR}/lib/pkgconfig:$ENV{QT_WINDOWS_DIR}/share/pkgconfig")
else()
set(ENV{PKG_CONFIG_LIBDIR} "/opt/mingw-sysroot/lib/pkgconfig:/opt/mingw-sysroot/share/pkgconfig")
endif()
+1 -1
View File
@@ -34,7 +34,7 @@ CI_SERVER_URL="${CI_SERVER_URL:-https://gitlab.com}"
RUNNER_NAME="${RUNNER_NAME:-asteria-qt-macos-runner}"
RUNNER_TAGS="${RUNNER_TAGS:-macos-qt}"
export QT_MACOS_DIR="${QT_MACOS_DIR:-/opt/qt/6.10.3/macos}"
export QT_MACOS_DIR="${QT_MACOS_DIR:-/opt/qt/6.12.0/macos}"
if command -v brew >/dev/null 2>&1; then
LIBARCHIVE_PREFIX="$(brew --prefix libarchive 2>/dev/null || true)"
if [ -n "${LIBARCHIVE_PREFIX}" ] && [ -d "${LIBARCHIVE_PREFIX}/lib/pkgconfig" ]; then
+55 -22
View File
@@ -1,21 +1,28 @@
#!/bin/bash
# Run CI build/package jobs locally using podman or docker.
# Usage: test-ci-linux.sh [--build-image]
# --build-image build the CI image from Dockerfile instead of pulling the prebuilt one
# Run Linux CI build/test/package jobs locally using podman or docker.
# Usage: test-ci-linux.sh [--build-image] [--image <tag>] [--arm64] [--only-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_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" ;;
*) 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 ;;
--arm64) RUN_ARM64=true; shift ;;
--only-arm64) RUN_ARM64=true; RUN_X86_64=false; shift ;;
*) echo "Unknown argument: $1"; exit 1 ;;
esac
done
@@ -34,19 +41,19 @@ if [ "$BUILD_IMAGE" = true ]; then
echo "==> Building CI image from $DOCKERFILE"
"$RUNTIME" build \
--platform linux/amd64 \
--build-arg QT_VERSION=6.10.3 \
--build-arg QT_VERSION=6.12.0 \
-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
mkdir -p "$OUTPUT_DIR"
# Helper: run a command inside the CI container
# The project is copied into /src inside the container so the build is isolated.
run_in_container() {
local extra_args=("$@")
"$RUNTIME" run --rm \
@@ -63,22 +70,48 @@ run_in_container() {
'
}
# ── Linux build ───────────────────────────────────────────────────────────────
echo "==> build-linux"
CI_SCRIPT='
# ── Linux x86_64 build, test, and package ────────────────────────────────────
if [ "$RUN_X86_64" = true ]; then
echo "==> build-linux & test-linux (x86_64)"
CI_SCRIPT='
cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="${QT_LINUX_DIR}"
cmake --build build-linux --target asteria-qt
cp build-linux/asteria-qt /out/
cmake --build build-linux
QT_QPA_PLATFORM=offscreen ctest --test-dir build-linux --output-on-failure
rm -rf /out/build-linux
cp -r build-linux /out/build-linux
cp build-linux/asteria-qt /out/asteria-qt
' run_in_container -v "$OUTPUT_DIR:/out"
echo "==> package-linux"
CI_SCRIPT='
mkdir -p build-linux
cp /out/asteria-qt build-linux/asteria-qt
echo "==> package-linux (x86_64)"
CI_SCRIPT='
cp -r /out/build-linux build-linux
chmod +x packaging/package-linux.sh
packaging/package-linux.sh build-linux "${QT_LINUX_DIR}" /out
packaging/package-linux.sh build-linux "${QT_LINUX_DIR}" /out x86_64
' run_in_container -v "$OUTPUT_DIR:/out"
fi
# ── Linux ARM64 build and package ────────────────────────────────────────────
if [ "$RUN_ARM64" = true ]; then
echo "==> build-linux-arm64"
CI_SCRIPT='
cmake -B build-linux-arm64 -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/src/scripts/linux-arm64-toolchain.cmake \
-DCMAKE_PREFIX_PATH="${QT_LINUX_ARM64_DIR}" \
-DQT_HOST_PATH="${QT_LINUX_DIR}"
cmake --build build-linux-arm64 --target asteria-qt
rm -rf /out/build-linux-arm64
cp -r build-linux-arm64 /out/build-linux-arm64
' run_in_container -v "$OUTPUT_DIR:/out"
echo "==> package-linux-arm64"
CI_SCRIPT='
cp -r /out/build-linux-arm64 build-linux-arm64
chmod +x packaging/package-linux.sh
packaging/package-linux.sh build-linux-arm64 "${QT_LINUX_ARM64_DIR}" /out arm64
' run_in_container -v "$OUTPUT_DIR:/out"
fi
echo ""
echo "==> Done. Artifacts in $OUTPUT_DIR/"
+32 -9
View File
@@ -1,9 +1,10 @@
#!/bin/bash
# Run CI build/package jobs locally using podman or docker.
# Usage: test-ci-windows.sh [--build-image] [--linux] [--arm64]
# Usage: test-ci-windows.sh [--build-image] [--image <tag>] [--linux] [--arm64] [--only-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
# --linux also run build-linux + package-linux (and arm64 if --arm64 is passed)
# --arm64 also run arm64 build + package jobs
# --only-arm64 run only arm64 build + package jobs
set -euo pipefail
export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"
@@ -46,7 +47,7 @@ if [ "$BUILD_IMAGE" = true ]; then
echo "==> Building CI image from $DOCKERFILE"
"$RUNTIME" build \
--platform linux/amd64 \
--build-arg QT_VERSION=6.10.3 \
--build-arg QT_VERSION=6.12.0 \
-t "$IMAGE_TAG" \
-f "$DOCKERFILE" \
"$PROJECT_DIR"
@@ -124,20 +125,42 @@ fi
# ── Linux build (optional) ───────────────────────────────────────────────────
if [ "$RUN_LINUX" = true ]; then
echo "==> build-linux"
if [ "$RUN_X86_64" = true ]; then
echo "==> build-linux (x86_64)"
CI_SCRIPT='
cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="${QT_LINUX_DIR}"
cmake --build build-linux --target asteria-qt
cp build-linux/asteria-qt /out/
cp -r build-linux /out/build-linux
' run_in_container -v "$OUTPUT_DIR:/out"
echo "==> package-linux"
echo "==> package-linux (x86_64)"
CI_SCRIPT='
cp /out/asteria-qt build-linux/asteria-qt
cp -r /out/build-linux build-linux
chmod +x packaging/package-linux.sh
packaging/package-linux.sh build-linux "${QT_LINUX_DIR}" /out
packaging/package-linux.sh build-linux "${QT_LINUX_DIR}" /out x86_64
' run_in_container -v "$OUTPUT_DIR:/out"
fi
if [ "$RUN_ARM64" = true ]; then
echo "==> build-linux-arm64"
CI_SCRIPT='
cmake -B build-linux-arm64 -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=/src/scripts/linux-arm64-toolchain.cmake \
-DCMAKE_PREFIX_PATH="${QT_LINUX_ARM64_DIR}" \
-DQT_HOST_PATH="${QT_LINUX_DIR}"
cmake --build build-linux-arm64 --target asteria-qt
cp -r build-linux-arm64 /out/build-linux-arm64
' run_in_container -v "$OUTPUT_DIR:/out"
echo "==> package-linux-arm64"
CI_SCRIPT='
cp -r /out/build-linux-arm64 build-linux-arm64
chmod +x packaging/package-linux.sh
packaging/package-linux.sh build-linux-arm64 "${QT_LINUX_ARM64_DIR}" /out arm64
' run_in_container -v "$OUTPUT_DIR:/out"
fi
fi
echo ""
+259 -144
View File
@@ -1,71 +1,109 @@
#!/usr/bin/env python3
"""
Verifies that all PE DLL dependencies of an executable and its bundled plugins
are satisfied within the target distribution directory.
Bundles (optional) and verifies that all non-system PE (.exe / .dll) import
dependencies in a Windows distribution folder are present inside the folder.
Usage:
verify-windows-dlls.py /path/to/dist_dir
verify-windows-dlls.py <dist-dir> [--bundle-from <dir> ...]
"""
import argparse
import os
import shutil
import struct
import sys
# Standard Windows system and runtime libraries (case-insensitive)
# Standard Windows OS system DLLs provided by Windows (System32)
SYSTEM_DLLS = {
# Core OS & NT subsystems
"ntdll.dll",
"kernel32.dll",
"kernelbase.dll",
"user32.dll",
"gdi32.dll",
"gdiplus.dll",
"shell32.dll",
"shlwapi.dll",
"ole32.dll",
"oleaut32.dll",
"comdlg32.dll",
"comctl32.dll",
"advapi32.dll",
"version.dll",
"ws2_32.dll",
"wsock32.dll",
"netapi32.dll",
"userenv.dll",
"winmm.dll",
"uxtheme.dll",
"dwmapi.dll",
"imm32.dll",
"crypt32.dll",
"bcrypt.dll",
"ncrypt.dll",
"secur32.dll",
"sspicli.dll",
"setupapi.dll",
"cfgmgr32.dll",
"iphlpapi.dll",
"dnsapi.dll",
"rpcrt4.dll",
"mpr.dll",
"authz.dll",
"wtsapi32.dll",
"propsys.dll",
"powrprof.dll",
"winspool.drv",
"shcore.dll",
"hid.dll",
# Graphics & DirectX
"bcrypt.dll",
"bcryptprimitives.dll",
"cabinet.dll",
"cfgmgr32.dll",
"combase.dll",
"comctl32.dll",
"comdlg32.dll",
"credui.dll",
"crypt32.dll",
"cryptbase.dll",
"d2d1.dll",
"d3d9.dll",
"d3d10warp.dll",
"d3d11.dll",
"d3d12.dll",
"dxgi.dll",
"d2d1.dll",
"d3dcompiler_47.dll",
"dbghelp.dll",
"dcomp.dll",
"dhcpcsvc.dll",
"dhcpcsvc6.dll",
"dnsapi.dll",
"dwmapi.dll",
"dwrite.dll",
"opengl32.dll",
"dxcore.dll",
"dxgi.dll",
"gdi32.dll",
"gdiplus.dll",
"glu32.dll",
# CRT / UCRT
"hid.dll",
"imagehlp.dll",
"imm32.dll",
"iphlpapi.dll",
"kernel32.dll",
"kernelbase.dll",
"ksuser.dll",
"mf.dll",
"mfplat.dll",
"mfreadwrite.dll",
"mfuuid.dll",
"mmdevapi.dll",
"mpr.dll",
"mscms.dll",
"msimg32.dll",
"msvcp_win.dll",
"msvcrt.dll",
"mswsock.dll",
"ncrypt.dll",
"netapi32.dll",
"netutils.dll",
"normaliz.dll",
"ntdll.dll",
"ole32.dll",
"oleaut32.dll",
"opengl32.dll",
"pdh.dll",
"powrprof.dll",
"propsys.dll",
"psapi.dll",
"rpcrt4.dll",
"runtimeobject.dll",
"secur32.dll",
"setupapi.dll",
"shcore.dll",
"shell32.dll",
"shlwapi.dll",
"srvcli.dll",
"synchronization.dll",
"ucrtbase.dll",
"uiautomationcore.dll",
"urlmon.dll",
"user32.dll",
"userenv.dll",
"usp10.dll",
"uxtheme.dll",
"version.dll",
"vulkan-1.dll",
"wevtapi.dll",
"winhttp.dll",
"wininet.dll",
"winmm.dll",
"winspool.drv",
"wkscli.dll",
"wldap32.dll",
"ws2_32.dll",
"wtsapi32.dll",
"xinput1_4.dll",
"xmllite.dll",
}
@@ -78,137 +116,214 @@ def is_system_dll(name):
return False
def get_pe_imports(file_path):
try:
with open(file_path, "rb") as f:
def rva_to_offset(rva, sections):
for vaddr, vsize, raw_ptr, raw_size in sections:
size = max(vsize, raw_size)
if vaddr <= rva < vaddr + size:
return raw_ptr + (rva - vaddr)
return None
def read_cstring(data, offset):
if offset is None or offset < 0 or offset >= len(data):
return None
end = data.find(b"\x00", offset)
if end == -1:
return None
return data[offset:end].decode("ascii", errors="replace")
def get_pe_imports(filepath):
with open(filepath, "rb") as f:
data = f.read()
except Exception as e:
print(f"Warning: could not read {file_path}: {e}", file=sys.stderr)
return []
if len(data) < 0x40 or data[:2] != b"MZ":
return []
pe_offset = struct.unpack_from("<I", data, 0x3c)[0]
if pe_offset + 24 > len(data) or data[pe_offset:pe_offset+4] != b"PE\x00\x00":
return []
magic = struct.unpack_from("<H", data, pe_offset + 24)[0]
if magic == 0x20b: # PE32+ (64-bit)
import_rva_offset = pe_offset + 24 + 120
elif magic == 0x10b: # PE32 (32-bit)
import_rva_offset = pe_offset + 24 + 104
else:
return []
if import_rva_offset + 8 > len(data):
return []
import_rva, import_size = struct.unpack_from("<II", data, import_rva_offset)
if import_rva == 0 or import_size == 0:
pe_offset = struct.unpack_from("<I", data, 0x3C)[0]
if pe_offset + 24 > len(data) or data[pe_offset : pe_offset + 4] != b"PE\x00\x00":
return []
num_sections = struct.unpack_from("<H", data, pe_offset + 6)[0]
size_of_opt_header = struct.unpack_from("<H", data, pe_offset + 20)[0]
sec_offset = pe_offset + 24 + size_of_opt_header
opt_header_size = struct.unpack_from("<H", data, pe_offset + 20)[0]
opt_offset = pe_offset + 24
if opt_offset + opt_header_size > len(data):
return []
magic = struct.unpack_from("<H", data, opt_offset)[0]
if magic == 0x20B: # PE32+ (64-bit: x86_64 / ARM64)
dd_offset = opt_offset + 112
elif magic == 0x10B: # PE32 (32-bit)
dd_offset = opt_offset + 96
else:
return []
num_rva = struct.unpack_from("<I", data, dd_offset - 4)[0]
if num_rva < 2:
return []
import_rva, import_size = struct.unpack_from("<II", data, dd_offset + 8)
if import_rva == 0 or import_size == 0:
return []
sec_offset = opt_offset + opt_header_size
sections = []
for i in range(num_sections):
sec = data[sec_offset + i * 40 : sec_offset + (i + 1) * 40]
if len(sec) < 40:
s_off = sec_offset + i * 40
if s_off + 40 > len(data):
break
vsize, vrva, rsize, roffset = struct.unpack_from("<IIII", sec, 8)
sections.append((vrva, vsize, roffset, rsize))
vsize, vaddr, raw_size, raw_ptr = struct.unpack_from("<IIII", data, s_off + 8)
sections.append((vaddr, vsize, raw_ptr, raw_size))
def rva_to_off(rva):
for vrva, vsize, roffset, rsize in sections:
if vrva <= rva < vrva + max(vsize, rsize):
return roffset + (rva - vrva)
return None
import_off = rva_to_off(import_rva)
if not import_off:
imp_offset = rva_to_offset(import_rva, sections)
if imp_offset is None:
return []
imports = []
while import_off + 20 <= len(data):
desc = data[import_off : import_off + 20]
if desc == b"\x00" * 20:
pos = imp_offset
while pos + 20 <= len(data):
orig_thunk, ts, fwd, name_rva, first_thunk = struct.unpack_from("<IIIII", data, pos)
if orig_thunk == 0 and name_rva == 0 and first_thunk == 0:
break
name_rva = struct.unpack_from("<I", desc, 12)[0]
name_off = rva_to_off(name_rva)
if name_off and name_off < len(data):
name = data[name_off:].split(b"\x00", 1)[0].decode("latin1", errors="ignore")
if name:
imports.append(name)
import_off += 20
name_off = rva_to_offset(name_rva, sections)
dll_name = read_cstring(data, name_off)
if dll_name:
imports.append(dll_name)
pos += 20
return imports
def verify_dist_directory(dist_dir):
if not os.path.isdir(dist_dir):
print(f"Error: directory does not exist: {dist_dir}", file=sys.stderr)
return False
def collect_pe_files(dist_dir):
pe_files = []
for root, _, files in os.walk(dist_dir):
for fname in files:
lower = fname.lower()
if lower.endswith(".dll") or lower.endswith(".exe"):
pe_files.append(os.path.join(root, fname))
return sorted(pe_files)
# Collect all available DLLs in the dist directory (case-insensitive)
available_dlls = {}
binaries = []
def bundle_transitive_dlls(dist_dir, search_dirs):
"""
Walks all PE files in dist_dir and recursively copies required non-system DLLs
from search_dirs into dist_dir root.
"""
# Build case-insensitive lookup index of available DLLs in search_dirs
available = {}
for sdir in search_dirs:
if not sdir or not os.path.isdir(sdir):
continue
for fname in os.listdir(sdir):
if fname.lower().endswith(".dll"):
lower = fname.lower()
if lower not in available:
available[lower] = os.path.join(sdir, fname)
# Track DLLs already present in dist_dir
present = set()
queue = []
for full_path in collect_pe_files(dist_dir):
present.add(os.path.basename(full_path).lower())
queue.append(full_path)
copied_count = 0
while queue:
current_pe = queue.pop(0)
current_dir = os.path.dirname(current_pe)
local_dlls = {
f.lower()
for f in os.listdir(current_dir)
if f.lower().endswith(".dll") or f.lower().endswith(".exe")
}
for imp in get_pe_imports(current_pe):
imp_lower = imp.lower()
if is_system_dll(imp_lower):
continue
if imp_lower in present or imp_lower in local_dlls:
continue
if imp_lower in available:
src_dll = available[imp_lower]
dst_dll = os.path.join(dist_dir, os.path.basename(src_dll))
shutil.copy2(src_dll, dst_dll)
present.add(imp_lower)
queue.append(dst_dll)
copied_count += 1
print(f"==> Bundled {copied_count} transitive runtime DLLs into {dist_dir}")
def verify_dist_directory(dist_dir):
root_dlls = set()
all_pe_files = []
for root, _, files in os.walk(dist_dir):
for f in files:
lower = f.lower()
rel_path = os.path.relpath(os.path.join(root, f), dist_dir)
if lower.endswith(".dll"):
available_dlls[lower] = rel_path
binaries.append(os.path.join(root, f))
elif lower.endswith(".exe"):
binaries.append(os.path.join(root, f))
for fname in files:
lower = fname.lower()
if lower.endswith(".dll") or lower.endswith(".exe"):
full_path = os.path.join(root, fname)
all_pe_files.append(full_path)
if os.path.abspath(root) == os.path.abspath(dist_dir):
root_dlls.add(lower)
if not binaries:
print(f"Error: no .exe or .dll binaries found in {dist_dir}", file=sys.stderr)
return False
if not all_pe_files:
raise RuntimeError(f"No .exe or .dll files found in {dist_dir}")
missing_deps = []
checked_count = len(binaries)
for bin_path in binaries:
rel_bin = os.path.relpath(bin_path, dist_dir)
imports = get_pe_imports(bin_path)
for imp in imports:
if is_system_dll(imp):
continue
if imp.lower() not in available_dlls:
missing_deps.append((rel_bin, imp))
if missing_deps:
print(f"FAILED: Found {len(missing_deps)} missing DLL dependencies in {dist_dir}:", file=sys.stderr)
# Deduplicate and group by missing DLL
missing_by_dll = {}
for rel_bin, imp in missing_deps:
missing_by_dll.setdefault(imp, []).append(rel_bin)
for pe_file in sorted(all_pe_files):
rel_pe = os.path.relpath(pe_file, dist_dir)
local_dir = os.path.dirname(pe_file)
local_dlls = {
f.lower()
for f in os.listdir(local_dir)
if f.lower().endswith(".dll") or f.lower().endswith(".exe")
}
for imp, users in sorted(missing_by_dll.items()):
print(f" [MISSING] {imp} needed by:", file=sys.stderr)
for u in users[:5]:
print(f" - {u}", file=sys.stderr)
if len(users) > 5:
print(f" ... and {len(users) - 5} more", file=sys.stderr)
return False
for imp in get_pe_imports(pe_file):
imp_lower = imp.lower()
if is_system_dll(imp_lower):
continue
if imp_lower not in root_dlls and imp_lower not in local_dlls:
missing_by_dll.setdefault(imp, []).append(rel_pe)
print(f"OK: Verified {checked_count} binaries. All external DLL imports satisfied ({len(available_dlls)} DLLs bundled).")
return True
if missing_by_dll:
print(f"FAILED: Found {len(missing_by_dll)} missing DLL dependencies in {dist_dir}:", file=sys.stderr)
for dll, importers in sorted(missing_by_dll.items()):
print(f" [MISSING] {dll} needed by:", file=sys.stderr)
for importer in importers[:5]:
print(f" - {importer}", file=sys.stderr)
if len(importers) > 5:
print(f" ... and {len(importers) - 5} more", file=sys.stderr)
sys.exit(1)
print(
f"==> DLL verification passed: scanned {len(all_pe_files)} binaries in {dist_dir}, "
"0 missing dependencies."
)
def main():
if len(sys.argv) < 2:
print("Usage: verify-windows-dlls.py <dist-dir>", file=sys.stderr)
sys.exit(2)
parser = argparse.ArgumentParser(description="Bundle and verify PE DLL imports in a Windows dist directory")
parser.add_argument("dist_dir", help="Path to the distribution directory containing asteria-qt.exe")
parser.add_argument(
"--bundle-from",
nargs="+",
default=[],
help="Optional list of bin directories to copy transitive DLL dependencies from before verifying",
)
args = parser.parse_args()
dist_dir = sys.argv[1]
if not verify_dist_directory(dist_dir):
if not os.path.isdir(args.dist_dir):
print(f"Error: directory does not exist: {args.dist_dir}", file=sys.stderr)
sys.exit(1)
if args.bundle_from:
bundle_transitive_dlls(args.dist_dir, args.bundle_from)
verify_dist_directory(args.dist_dir)
if __name__ == "__main__":
main()