moaaar ci changes
This commit is contained in:
7 files changed
+475
-147
No files matched your search
+84
-14
@@ -21,6 +21,7 @@ workflow:
|
||||
CI_PIPELINE_TYPE: normal
|
||||
- changes:
|
||||
- docker/Dockerfile.build
|
||||
- docker/entrypoint.sh
|
||||
- scripts/download-mingw-arm64-qt.py
|
||||
- scripts/install-deps-ubuntu.sh
|
||||
- scripts/linux-arm64-toolchain.cmake
|
||||
@@ -40,31 +41,100 @@ stages:
|
||||
variables:
|
||||
GIT_CLEAN_FLAGS: -fdx
|
||||
|
||||
# ── Build the runner image and push to registry ────────────────────────────────
|
||||
build-docker:
|
||||
# ── Build split runner images and push to registry ─────────────────────────────
|
||||
.build-docker-base:
|
||||
stage: build
|
||||
image: docker:27
|
||||
services:
|
||||
- docker:27-dind
|
||||
variables:
|
||||
DOCKER_TLS_CERTDIR: "/certs"
|
||||
DOCKER_IMAGE: "${CI_REGISTRY_IMAGE}/build-env:latest"
|
||||
DOCKER_BUILDKIT: "1"
|
||||
before_script:
|
||||
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_REGISTRY_PASSWORD}" "${CI_REGISTRY}"
|
||||
script:
|
||||
- docker build
|
||||
--pull
|
||||
--build-arg QT_VERSION=6.12.0
|
||||
--build-arg BUILDKIT_INLINE_CACHE=1
|
||||
--cache-from "${DOCKER_IMAGE}"
|
||||
--target "${DOCKER_TARGET}"
|
||||
-t "${DOCKER_IMAGE}"
|
||||
-f docker/Dockerfile.build .
|
||||
- docker push "${DOCKER_IMAGE}"
|
||||
|
||||
build-docker-linux-x86_64:
|
||||
extends: .build-docker-base
|
||||
variables:
|
||||
DOCKER_TARGET: "linux-x86_64"
|
||||
DOCKER_IMAGE: "${CI_REGISTRY_IMAGE}/build-linux-x86_64:latest"
|
||||
rules:
|
||||
- if: $CI_PIPELINE_TYPE == "image-rebuild"
|
||||
- if: $CI_PIPELINE_TYPE != "image-rebuild"
|
||||
when: never
|
||||
- if: '"$[[ inputs.FORCE_REBUILD_IMAGE ]]" == "true" || $FORCE_REBUILD_IMAGE == "true"'
|
||||
when: on_success
|
||||
- changes:
|
||||
- docker/Dockerfile.build
|
||||
- docker/entrypoint.sh
|
||||
- scripts/install-deps-ubuntu.sh
|
||||
when: on_success
|
||||
|
||||
build-docker-linux-arm64:
|
||||
extends: .build-docker-base
|
||||
variables:
|
||||
DOCKER_TARGET: "linux-arm64"
|
||||
DOCKER_IMAGE: "${CI_REGISTRY_IMAGE}/build-linux-arm64:latest"
|
||||
rules:
|
||||
- if: $CI_PIPELINE_TYPE != "image-rebuild"
|
||||
when: never
|
||||
- if: '"$[[ inputs.FORCE_REBUILD_IMAGE ]]" == "true" || $FORCE_REBUILD_IMAGE == "true"'
|
||||
when: on_success
|
||||
- changes:
|
||||
- docker/Dockerfile.build
|
||||
- docker/entrypoint.sh
|
||||
- scripts/install-deps-ubuntu.sh
|
||||
- scripts/linux-arm64-toolchain.cmake
|
||||
when: on_success
|
||||
|
||||
build-docker-windows-x86_64:
|
||||
extends: .build-docker-base
|
||||
variables:
|
||||
DOCKER_TARGET: "windows-x86_64"
|
||||
DOCKER_IMAGE: "${CI_REGISTRY_IMAGE}/build-windows-x86_64:latest"
|
||||
rules:
|
||||
- if: $CI_PIPELINE_TYPE != "image-rebuild"
|
||||
when: never
|
||||
- if: '"$[[ inputs.FORCE_REBUILD_IMAGE ]]" == "true" || $FORCE_REBUILD_IMAGE == "true"'
|
||||
when: on_success
|
||||
- changes:
|
||||
- docker/Dockerfile.build
|
||||
- docker/entrypoint.sh
|
||||
- scripts/download-mingw-arm64-qt.py
|
||||
- scripts/mingw-w64-toolchain.cmake
|
||||
when: on_success
|
||||
|
||||
build-docker-windows-arm64:
|
||||
extends: .build-docker-base
|
||||
variables:
|
||||
DOCKER_TARGET: "windows-arm64"
|
||||
DOCKER_IMAGE: "${CI_REGISTRY_IMAGE}/build-windows-arm64:latest"
|
||||
rules:
|
||||
- if: $CI_PIPELINE_TYPE != "image-rebuild"
|
||||
when: never
|
||||
- if: '"$[[ inputs.FORCE_REBUILD_IMAGE ]]" == "true" || $FORCE_REBUILD_IMAGE == "true"'
|
||||
when: on_success
|
||||
- changes:
|
||||
- docker/Dockerfile.build
|
||||
- docker/entrypoint.sh
|
||||
- scripts/download-mingw-arm64-qt.py
|
||||
- scripts/mingw-w64-arm64-toolchain.cmake
|
||||
when: on_success
|
||||
|
||||
# ── Linux native build (x86_64) ────────────────────────────────────────────────
|
||||
build-linux:
|
||||
interruptible: true
|
||||
tags:
|
||||
- linux-qt
|
||||
- linux-x86_64
|
||||
stage: build
|
||||
script:
|
||||
- cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release
|
||||
@@ -85,7 +155,7 @@ build-linux:
|
||||
build-linux-arm64:
|
||||
interruptible: true
|
||||
tags:
|
||||
- linux-qt
|
||||
- linux-arm64
|
||||
stage: build
|
||||
script:
|
||||
- cmake -B build-linux-arm64 -G Ninja
|
||||
@@ -109,7 +179,7 @@ build-linux-arm64:
|
||||
build-windows:
|
||||
interruptible: true
|
||||
tags:
|
||||
- linux-qt
|
||||
- windows-x86_64
|
||||
stage: build
|
||||
script:
|
||||
- PKG_CONFIG_PATH="${MINGW_SYSROOT}/lib/pkgconfig" cmake -B build-windows -G Ninja
|
||||
@@ -134,7 +204,7 @@ build-windows:
|
||||
build-windows-arm64:
|
||||
interruptible: true
|
||||
tags:
|
||||
- linux-qt
|
||||
- windows-arm64
|
||||
stage: build
|
||||
script:
|
||||
- PKG_CONFIG_PATH="${MINGW_ARM64_SYSROOT}/lib/pkgconfig" cmake -B build-windows-arm64 -G Ninja
|
||||
@@ -184,7 +254,7 @@ build-macos:
|
||||
test-linux:
|
||||
interruptible: true
|
||||
tags:
|
||||
- linux-qt
|
||||
- linux-x86_64
|
||||
stage: test
|
||||
needs: []
|
||||
script:
|
||||
@@ -222,7 +292,7 @@ test-macos:
|
||||
package-linux:
|
||||
interruptible: true
|
||||
tags:
|
||||
- linux-qt
|
||||
- linux-x86_64
|
||||
stage: package
|
||||
needs:
|
||||
- build-linux
|
||||
@@ -245,7 +315,7 @@ package-linux:
|
||||
package-linux-arm64:
|
||||
interruptible: true
|
||||
tags:
|
||||
- linux-qt
|
||||
- linux-arm64
|
||||
stage: package
|
||||
needs:
|
||||
- build-linux-arm64
|
||||
@@ -268,7 +338,7 @@ package-linux-arm64:
|
||||
package-windows:
|
||||
interruptible: true
|
||||
tags:
|
||||
- linux-qt
|
||||
- windows-x86_64
|
||||
stage: package
|
||||
needs:
|
||||
- build-windows
|
||||
@@ -290,7 +360,7 @@ package-windows:
|
||||
package-windows-arm64:
|
||||
interruptible: true
|
||||
tags:
|
||||
- linux-qt
|
||||
- windows-arm64
|
||||
stage: package
|
||||
needs:
|
||||
- build-windows-arm64
|
||||
@@ -340,7 +410,7 @@ package-macos:
|
||||
update-wiki:
|
||||
stage: wiki
|
||||
tags:
|
||||
- linux-qt
|
||||
- linux-x86_64
|
||||
needs:
|
||||
- package-linux
|
||||
- package-linux-arm64
|
||||
|
||||
@@ -97,7 +97,7 @@ packaging/package-windows.sh build-windows-arm64 /opt/qt/6.12.0/mingw_arm64 /opt
|
||||
```
|
||||
|
||||
### 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):
|
||||
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; CI targets also use `--skip-qt`, `--only-arm64`, and `--prune-qt`):
|
||||
```bash
|
||||
# Native x86_64 build & tests
|
||||
cmake -S . -B build -G Ninja \
|
||||
@@ -120,6 +120,16 @@ 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
|
||||
```
|
||||
|
||||
### GitLab CI Split Docker Images (`docker/Dockerfile.build`)
|
||||
The CI environment is split into 4 multi-stage targets on `ubuntu:24.04` sharing a common `base` layer (core CLI tools, host `QT_LINUX_DIR` for `QT_HOST_PATH`, and `gitlab-runner`) plus `linux-base` / `windows-base` intermediate layers:
|
||||
| Image | Docker `--target` | Runner Tag | Purpose |
|
||||
|---|---|---|---|
|
||||
| `${CI_REGISTRY_IMAGE}/build-linux-x86_64:latest` | `linux-x86_64` | `linux-x86_64` | `build-linux`, `test-linux`, `package-linux`, `update-wiki` |
|
||||
| `${CI_REGISTRY_IMAGE}/build-linux-arm64:latest` | `linux-arm64` | `linux-arm64` | `build-linux-arm64`, `package-linux-arm64` |
|
||||
| `${CI_REGISTRY_IMAGE}/build-windows-x86_64:latest` | `windows-x86_64` | `windows-x86_64` | `build-windows`, `package-windows` |
|
||||
| `${CI_REGISTRY_IMAGE}/build-windows-arm64:latest` | `windows-arm64` | `windows-arm64` | `build-windows-arm64`, `package-windows-arm64` |
|
||||
In `.gitlab-ci.yml`, `image-rebuild` pipelines rebuild only the affected target image(s) when relevant files change, or all 4 in parallel when `FORCE_REBUILD_IMAGE=true`.
|
||||
|
||||
### macOS Build Environment
|
||||
```bash
|
||||
scripts/install-deps-macos.sh
|
||||
|
||||
+162
-52
@@ -1,64 +1,63 @@
|
||||
FROM ubuntu:24.04
|
||||
# Multi-stage CI runner images for asteria-qt (all sharing the `base` layer).
|
||||
# Targets:
|
||||
# - linux-x86_64 : Native Linux x86_64 build, CTest, AppImage packaging, and wiki jobs
|
||||
# - linux-arm64 : Cross-compiled Linux ARM64 build and AppImage packaging
|
||||
# - windows-x86_64 : Cross-compiled Windows x86_64 build and portable zip packaging
|
||||
# - windows-arm64 : Cross-compiled Windows ARM64 build and portable zip packaging
|
||||
|
||||
FROM ubuntu:24.04 AS base
|
||||
|
||||
ARG QT_VERSION=6.12.0
|
||||
ARG QT_INSTALL_DIR=/opt/qt
|
||||
ARG LLVM_MINGW_VERSION=20240917
|
||||
|
||||
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}
|
||||
|
||||
# ── 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/*
|
||||
|
||||
# ── 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="/opt/llvm-mingw/bin:${PATH}"
|
||||
|
||||
# ── 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 --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
|
||||
|
||||
# ── 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
|
||||
|
||||
# ── 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 && \
|
||||
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
|
||||
# ── Core CLI tools, Qt host runtime libs, and host Qt 6 (QT_HOST_PATH) ─────────
|
||||
RUN apt-get update -qq && \
|
||||
apt-get install -y --no-install-recommends \
|
||||
ca-certificates \
|
||||
cmake \
|
||||
curl \
|
||||
file \
|
||||
git \
|
||||
jq \
|
||||
libdbus-1-3 \
|
||||
libegl1 \
|
||||
libfontconfig1 \
|
||||
libfreetype6 \
|
||||
libgl1 \
|
||||
libglib2.0-0t64 \
|
||||
libxkbcommon0 \
|
||||
ninja-build \
|
||||
pkg-config \
|
||||
python3 \
|
||||
python3-venv \
|
||||
wget \
|
||||
xz-utils \
|
||||
zip \
|
||||
zstd \
|
||||
&& rm -rf /var/lib/apt/lists/* \
|
||||
&& python3 -m venv /tmp/aqt-venv \
|
||||
&& /tmp/aqt-venv/bin/pip install --quiet aqtinstall \
|
||||
&& /tmp/aqt-venv/bin/aqt install-qt linux desktop "${QT_VERSION}" linux_gcc_64 \
|
||||
-m qtimageformats --outputdir "${QT_INSTALL_DIR}" \
|
||||
&& rm -rf /tmp/aqt-venv \
|
||||
&& rm -rf \
|
||||
"${QT_LINUX_DIR}/doc" \
|
||||
"${QT_LINUX_DIR}/examples" \
|
||||
"${QT_LINUX_DIR}/phrasebooks" \
|
||||
"${QT_LINUX_DIR}/translations" \
|
||||
"${QT_LINUX_DIR}/qml/QtQuick/LocalStorage" \
|
||||
"${QT_LINUX_DIR}/qml/QtQuick/Particles" \
|
||||
"${QT_LINUX_DIR}/qml/QtQuick/Pdf" \
|
||||
"${QT_LINUX_DIR}/qml/QtQuick/Scene2D" \
|
||||
"${QT_LINUX_DIR}/qml/QtQuick/Scene3D" \
|
||||
"${QT_LINUX_DIR}/qml/QtQuick/Timeline" \
|
||||
"${QT_LINUX_DIR}/qml/QtQuick/VirtualKeyboard" \
|
||||
"${QT_LINUX_DIR}/qml/QtQuick/tooling"
|
||||
|
||||
# ── gitlab-runner (shell executor) ─────────────────────────────────────────────
|
||||
RUN wget -q https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-amd64 \
|
||||
@@ -72,3 +71,114 @@ RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
CMD []
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Shared Linux packaging layer (patchelf + binutils/readelf + appimagetool)
|
||||
# ==============================================================================
|
||||
FROM base AS linux-base
|
||||
|
||||
# Note: Zeroing AppImage magic bytes 8-10 allows extraction under both native Linux and Rosetta 2
|
||||
RUN apt-get update -qq && \
|
||||
apt-get install -y --no-install-recommends binutils patchelf && \
|
||||
rm -rf /var/lib/apt/lists/* && \
|
||||
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
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Target 1: Linux x86_64 (native build, CTest, AppImage, wiki)
|
||||
# ==============================================================================
|
||||
FROM linux-base AS linux-x86_64
|
||||
|
||||
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 --skip-qt && \
|
||||
rm -rf /tmp/install-deps-ubuntu.sh /var/lib/apt/lists/* && \
|
||||
wget -q https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-x86_64 \
|
||||
-O /opt/appimage/runtime-x86_64 && \
|
||||
chmod +x /opt/appimage/runtime-x86_64 && \
|
||||
g++ --version
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Target 2: Linux ARM64 (aarch64 cross-compile + AppImage)
|
||||
# ==============================================================================
|
||||
FROM linux-base AS linux-arm64
|
||||
|
||||
ENV QT_LINUX_ARM64_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/gcc_arm64
|
||||
|
||||
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 --only-arm64 --prune-qt && \
|
||||
rm -rf /tmp/install-deps-ubuntu.sh /var/lib/apt/lists/* && \
|
||||
wget -q https://github.com/AppImage/type2-runtime/releases/download/continuous/runtime-aarch64 \
|
||||
-O /opt/appimage/runtime-aarch64 && \
|
||||
chmod +x /opt/appimage/runtime-aarch64
|
||||
|
||||
COPY scripts/linux-arm64-toolchain.cmake /opt/linux-arm64-toolchain.cmake
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Shared Windows cross-compilation base (llvm-mingw pruned to 64-bit targets)
|
||||
# ==============================================================================
|
||||
FROM base AS windows-base
|
||||
|
||||
ARG LLVM_MINGW_VERSION=20240917
|
||||
|
||||
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 -rf /tmp/llvm-mingw.tar.xz \
|
||||
/opt/llvm-mingw/i686-w64-mingw32 \
|
||||
/opt/llvm-mingw/armv7-w64-mingw32 \
|
||||
/opt/llvm-mingw/bin/i686-* \
|
||||
/opt/llvm-mingw/bin/armv7-*
|
||||
|
||||
ENV PATH="/opt/llvm-mingw/bin:${PATH}"
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Target 3: Windows x86_64 (LLVM-MinGW + MSYS2 clang64 Qt 6)
|
||||
# ==============================================================================
|
||||
FROM windows-base AS windows-x86_64
|
||||
|
||||
ENV QT_WINDOWS_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/mingw_64
|
||||
ENV MINGW_SYSROOT=${QT_WINDOWS_DIR}
|
||||
|
||||
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 --arch x86_64 --dest "${QT_WINDOWS_DIR}" && \
|
||||
ln -sfn "${QT_WINDOWS_DIR}" /opt/mingw-sysroot && \
|
||||
rm /tmp/download-mingw-arm64-qt.py && \
|
||||
x86_64-w64-mingw32-g++ --version
|
||||
|
||||
COPY scripts/mingw-w64-toolchain.cmake /opt/mingw-w64-toolchain.cmake
|
||||
|
||||
|
||||
# ==============================================================================
|
||||
# Target 4: Windows ARM64 (LLVM-MinGW + MSYS2 clangarm64 Qt 6)
|
||||
# ==============================================================================
|
||||
FROM windows-base AS windows-arm64
|
||||
|
||||
ENV QT_WINDOWS_ARM64_DIR=${QT_INSTALL_DIR}/${QT_VERSION}/mingw_arm64
|
||||
ENV MINGW_ARM64_SYSROOT=${QT_WINDOWS_ARM64_DIR}
|
||||
|
||||
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 --arch arm64 --dest "${QT_WINDOWS_ARM64_DIR}" && \
|
||||
ln -sfn "${QT_WINDOWS_ARM64_DIR}" /opt/mingw-arm64-sysroot && \
|
||||
rm /tmp/download-mingw-arm64-qt.py && \
|
||||
aarch64-w64-mingw32-g++ --version
|
||||
|
||||
COPY scripts/mingw-w64-arm64-toolchain.cmake /opt/mingw-w64-arm64-toolchain.cmake
|
||||
@@ -9,6 +9,7 @@ Usage:
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import concurrent.futures
|
||||
import glob
|
||||
import io
|
||||
import os
|
||||
@@ -17,6 +18,7 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import tempfile
|
||||
import urllib.error
|
||||
import urllib.request
|
||||
|
||||
@@ -176,42 +178,79 @@ def resolve_dependencies(packages, provides_map, pkg_prefix):
|
||||
return sorted(resolved)
|
||||
|
||||
|
||||
def download_and_extract_packages(resolved, repo, dest_dir):
|
||||
os.makedirs(dest_dir, exist_ok=True)
|
||||
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
|
||||
def _download_single_package(pkg_info, repo, download_dir):
|
||||
idx, total, filename = pkg_info
|
||||
last_err = None
|
||||
dest_file = os.path.join(download_dir, os.path.basename(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:
|
||||
with open(dest_file, "wb") as f:
|
||||
f.write(data)
|
||||
downloaded = True
|
||||
break
|
||||
print(f"[{idx}/{total}] Downloaded {filename}")
|
||||
return filename, dest_file
|
||||
except Exception as e:
|
||||
last_err = e
|
||||
print(f" Failed from {base}/{repo} ({e}), trying next mirror...", file=sys.stderr)
|
||||
print(f" Failed {filename} from {base}/{repo} ({e}), trying next mirror...", file=sys.stderr)
|
||||
|
||||
if not downloaded:
|
||||
raise RuntimeError(f"Failed to download {filename}: {last_err}")
|
||||
|
||||
|
||||
def download_and_extract_packages(resolved, repo, dest_dir):
|
||||
os.makedirs(dest_dir, exist_ok=True)
|
||||
total = len(resolved)
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix=f"msys2_{repo}_") as download_dir:
|
||||
tasks = [(i, total, filename) for i, (_, filename) in enumerate(resolved, 1)]
|
||||
downloaded_files = []
|
||||
|
||||
with concurrent.futures.ThreadPoolExecutor(max_workers=8) as executor:
|
||||
futures = [executor.submit(_download_single_package, task, repo, download_dir) for task in tasks]
|
||||
for future in concurrent.futures.as_completed(futures):
|
||||
downloaded_files.append(future.result())
|
||||
|
||||
# Extract sequentially in deterministic filename order
|
||||
for filename, pkg_path in sorted(downloaded_files):
|
||||
tar_res = subprocess.run(
|
||||
["tar", "-I", "zstd", "-xf", temp_pkg, "--strip-components=1", "-C", dest_dir],
|
||||
["tar", "-I", "zstd", "-xf", pkg_path, "--strip-components=1", "-C", dest_dir],
|
||||
capture_output=True,
|
||||
)
|
||||
if os.path.exists(temp_pkg):
|
||||
os.remove(temp_pkg)
|
||||
|
||||
os.remove(pkg_path)
|
||||
if tar_res.returncode != 0:
|
||||
err = tar_res.stderr.decode("utf-8", errors="replace")
|
||||
raise RuntimeError(f"Failed to extract {filename}: {err}")
|
||||
|
||||
|
||||
def prune_sysroot(abs_dest):
|
||||
# Remove docs, manuals, locales, translations, and examples
|
||||
prune_dirs = [
|
||||
os.path.join(abs_dest, "share", "doc"),
|
||||
os.path.join(abs_dest, "share", "man"),
|
||||
os.path.join(abs_dest, "share", "info"),
|
||||
os.path.join(abs_dest, "share", "locale"),
|
||||
os.path.join(abs_dest, "share", "qt6", "doc"),
|
||||
os.path.join(abs_dest, "share", "qt6", "examples"),
|
||||
os.path.join(abs_dest, "share", "qt6", "translations"),
|
||||
os.path.join(abs_dest, "share", "qt6", "phrasebooks"),
|
||||
]
|
||||
for unused_qml in ("LocalStorage", "Particles", "Pdf", "Scene2D", "Scene3D", "Timeline", "VirtualKeyboard", "tooling"):
|
||||
prune_dirs.append(os.path.join(abs_dest, "share", "qt6", "qml", "QtQuick", unused_qml))
|
||||
|
||||
for d in prune_dirs:
|
||||
if os.path.isdir(d):
|
||||
shutil.rmtree(d)
|
||||
|
||||
# Remove static .a archives when a corresponding .dll.a import library exists
|
||||
lib_dir = os.path.join(abs_dest, "lib")
|
||||
if os.path.isdir(lib_dir):
|
||||
for dll_a in glob.glob(os.path.join(lib_dir, "*.dll.a")):
|
||||
static_a = dll_a[: -len(".dll.a")] + ".a"
|
||||
if os.path.isfile(static_a):
|
||||
os.remove(static_a)
|
||||
|
||||
|
||||
def configure_sysroot(dest_dir, repo):
|
||||
abs_dest = os.path.abspath(dest_dir)
|
||||
|
||||
@@ -241,6 +280,8 @@ def configure_sysroot(dest_dir, repo):
|
||||
if os.path.isdir(tools_dir):
|
||||
shutil.rmtree(tools_dir)
|
||||
|
||||
prune_sysroot(abs_dest)
|
||||
|
||||
|
||||
def verify_installation(dest_dir):
|
||||
bin_dir = os.path.join(dest_dir, "bin")
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# Run with sudo or as root.
|
||||
#
|
||||
# Usage:
|
||||
# sudo scripts/install-deps-ubuntu.sh [--with-arm64] [--with-sources]
|
||||
# sudo scripts/install-deps-ubuntu.sh [--with-arm64] [--only-arm64] [--skip-qt] [--prune-qt] [--with-sources]
|
||||
#
|
||||
# Environment variables:
|
||||
# QT_VERSION Qt version to install via aqtinstall (default: 6.12.0)
|
||||
@@ -14,15 +14,21 @@ set -euo pipefail
|
||||
QT_VERSION="${QT_VERSION:-6.12.0}"
|
||||
QT_INSTALL_DIR="${QT_INSTALL_DIR:-/opt/qt}"
|
||||
WITH_ARM64=false
|
||||
ONLY_ARM64=false
|
||||
SKIP_QT=false
|
||||
PRUNE_QT=false
|
||||
WITH_SOURCES=false
|
||||
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--with-arm64) WITH_ARM64=true ;;
|
||||
--only-arm64) ONLY_ARM64=true; WITH_ARM64=true ;;
|
||||
--skip-qt) SKIP_QT=true ;;
|
||||
--prune-qt) PRUNE_QT=true ;;
|
||||
--with-sources) WITH_SOURCES=true ;;
|
||||
*)
|
||||
echo "Unknown option: $arg" >&2
|
||||
echo "Usage: $0 [--with-arm64] [--with-sources]" >&2
|
||||
echo "Usage: $0 [--with-arm64] [--only-arm64] [--skip-qt] [--prune-qt] [--with-sources]" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
@@ -55,7 +61,10 @@ fi
|
||||
echo "==> Installing system build tools and libraries..."
|
||||
apt-get update -qq
|
||||
|
||||
PACKAGES=(
|
||||
PACKAGES=()
|
||||
|
||||
if [ "$ONLY_ARM64" = false ]; then
|
||||
PACKAGES+=(
|
||||
build-essential
|
||||
ca-certificates
|
||||
cmake
|
||||
@@ -103,10 +112,12 @@ PACKAGES=(
|
||||
zip
|
||||
zlib1g-dev
|
||||
zstd
|
||||
)
|
||||
)
|
||||
fi
|
||||
|
||||
if [ "$WITH_ARM64" = true ] && [ "$HOST_ARCH" = "amd64" ]; then
|
||||
PACKAGES+=(
|
||||
gcc-aarch64-linux-gnu
|
||||
g++-aarch64-linux-gnu
|
||||
libarchive13t64:arm64
|
||||
libdbus-1-dev:arm64
|
||||
@@ -140,11 +151,16 @@ if [ "$WITH_ARM64" = true ] && [ "$HOST_ARCH" = "amd64" ]; then
|
||||
libxkbcommon-x11-0:arm64
|
||||
zlib1g-dev:arm64
|
||||
)
|
||||
if [ "$ONLY_ARM64" = true ]; then
|
||||
# Dedicated arm64 build environment has no conflicting amd64 libarchive-dev
|
||||
PACKAGES+=(libarchive-dev:arm64)
|
||||
fi
|
||||
fi
|
||||
|
||||
apt-get install -y --no-install-recommends "${PACKAGES[@]}"
|
||||
|
||||
if [ "$WITH_ARM64" = true ] && [ "$HOST_ARCH" = "amd64" ]; then
|
||||
if [ "$ONLY_ARM64" = false ]; 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
|
||||
@@ -152,42 +168,76 @@ if [ "$WITH_ARM64" = true ] && [ "$HOST_ARCH" = "amd64" ]; then
|
||||
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
|
||||
command -v aarch64-linux-gnu-gcc >/dev/null
|
||||
command -v aarch64-linux-gnu-g++ >/dev/null
|
||||
aarch64-linux-gnu-g++ --version
|
||||
PKG_CONFIG_LIBDIR=/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig \
|
||||
pkg-config --exists minizip libarchive
|
||||
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
|
||||
prune_qt_dir() {
|
||||
local qt_dir="$1"
|
||||
if [ ! -d "$qt_dir" ]; then
|
||||
return
|
||||
fi
|
||||
rm -rf \
|
||||
"$qt_dir/doc" \
|
||||
"$qt_dir/examples" \
|
||||
"$qt_dir/phrasebooks" \
|
||||
"$qt_dir/translations" \
|
||||
"$qt_dir/qml/QtQuick/LocalStorage" \
|
||||
"$qt_dir/qml/QtQuick/Particles" \
|
||||
"$qt_dir/qml/QtQuick/Pdf" \
|
||||
"$qt_dir/qml/QtQuick/Scene2D" \
|
||||
"$qt_dir/qml/QtQuick/Scene3D" \
|
||||
"$qt_dir/qml/QtQuick/Timeline" \
|
||||
"$qt_dir/qml/QtQuick/VirtualKeyboard" \
|
||||
"$qt_dir/qml/QtQuick/tooling"
|
||||
}
|
||||
|
||||
QT_NATIVE_DIR="${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64"
|
||||
if [ "$HOST_ARCH" = "arm64" ]; then
|
||||
QT_NATIVE_DIR="${QT_INSTALL_DIR}/${QT_VERSION}/gcc_arm64"
|
||||
fi
|
||||
|
||||
if [ "$SKIP_QT" = false ]; then
|
||||
echo "==> Installing Qt ${QT_VERSION} via aqtinstall -> ${QT_INSTALL_DIR}..."
|
||||
python3 -m venv /tmp/aqt-venv
|
||||
/tmp/aqt-venv/bin/pip install --quiet aqtinstall
|
||||
|
||||
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
|
||||
[ "$PRUNE_QT" = true ] && prune_qt_dir "${QT_INSTALL_DIR}/${QT_VERSION}/gcc_arm64"
|
||||
else
|
||||
if [ "$ONLY_ARM64" = false ]; then
|
||||
/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"
|
||||
[ "$PRUNE_QT" = true ] && prune_qt_dir "${QT_INSTALL_DIR}/${QT_VERSION}/gcc_64"
|
||||
fi
|
||||
|
||||
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}"
|
||||
[ "$PRUNE_QT" = true ] && prune_qt_dir "${QT_INSTALL_DIR}/${QT_VERSION}/gcc_arm64"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$WITH_SOURCES" = true ]; then
|
||||
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
|
||||
fi
|
||||
|
||||
rm -rf /tmp/aqt-venv
|
||||
rm -rf /tmp/aqt-venv
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "==> All Ubuntu dependencies installed."
|
||||
echo " Qt ${QT_VERSION} native path: ${QT_NATIVE_DIR}"
|
||||
if [ "$ONLY_ARM64" = false ]; then
|
||||
echo " Qt ${QT_VERSION} native path: ${QT_NATIVE_DIR}"
|
||||
fi
|
||||
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=${QT_NATIVE_DIR}"
|
||||
echo " cmake --build build --parallel"
|
||||
+36
-20
@@ -9,17 +9,17 @@ 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="${PREBUILT_IMAGE:-registry.gitlab.com/asteria-bookreader/asteria-qt/build-env:latest}"
|
||||
IMAGE_TAG="$PREBUILT_IMAGE"
|
||||
IMAGE_PREFIX="${PREBUILT_IMAGE_PREFIX:-registry.gitlab.com/asteria-bookreader/asteria-qt}"
|
||||
CUSTOM_IMAGE=""
|
||||
BUILD_IMAGE=false
|
||||
RUN_X86_64=true
|
||||
RUN_ARM64=false
|
||||
|
||||
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 ;;
|
||||
--build-image) BUILD_IMAGE=true; shift ;;
|
||||
--image) CUSTOM_IMAGE="$2"; shift 2 ;;
|
||||
--image=*) CUSTOM_IMAGE="${1#*=}"; shift ;;
|
||||
--arm64) RUN_ARM64=true; shift ;;
|
||||
--only-arm64) RUN_ARM64=true; RUN_X86_64=false; shift ;;
|
||||
*) echo "Unknown argument: $1"; exit 1 ;;
|
||||
@@ -37,31 +37,39 @@ else
|
||||
fi
|
||||
echo "Using container runtime: $RUNTIME"
|
||||
|
||||
if [ "$BUILD_IMAGE" = true ]; then
|
||||
echo "==> Building CI image from $DOCKERFILE"
|
||||
"$RUNTIME" build \
|
||||
prepare_image() {
|
||||
local target="$1"
|
||||
local image_tag="${CUSTOM_IMAGE:-${IMAGE_PREFIX}/build-${target}:latest}"
|
||||
if [ "$BUILD_IMAGE" = true ]; then
|
||||
image_tag="${CUSTOM_IMAGE:-asteria-qt-ci-${target}:latest}"
|
||||
echo "==> Building CI image target '$target' ($image_tag) from $DOCKERFILE"
|
||||
DOCKER_BUILDKIT=1 "$RUNTIME" build \
|
||||
--platform linux/amd64 \
|
||||
--build-arg QT_VERSION=6.12.0 \
|
||||
-t "$IMAGE_TAG" \
|
||||
--target "$target" \
|
||||
-t "$image_tag" \
|
||||
-f "$DOCKERFILE" \
|
||||
"$PROJECT_DIR"
|
||||
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
|
||||
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"
|
||||
|
||||
run_in_container() {
|
||||
local image_tag="$1"
|
||||
shift
|
||||
local extra_args=("$@")
|
||||
"$RUNTIME" run --rm \
|
||||
--platform linux/amd64 \
|
||||
--entrypoint bash \
|
||||
-v "$PROJECT_DIR:/src-ro:ro" \
|
||||
"${extra_args[@]}" \
|
||||
"$IMAGE_TAG" \
|
||||
"$image_tag" \
|
||||
-c '
|
||||
set -euo pipefail
|
||||
cp -r /src-ro /src
|
||||
@@ -72,6 +80,10 @@ run_in_container() {
|
||||
|
||||
# ── Linux x86_64 build, test, and package ────────────────────────────────────
|
||||
if [ "$RUN_X86_64" = true ]; then
|
||||
prepare_image "linux-x86_64"
|
||||
X64_IMAGE="${CUSTOM_IMAGE:-${IMAGE_PREFIX}/build-linux-x86_64:latest}"
|
||||
[ "$BUILD_IMAGE" = true ] && X64_IMAGE="${CUSTOM_IMAGE:-asteria-qt-ci-linux-x86_64:latest}"
|
||||
|
||||
echo "==> build-linux & test-linux (x86_64)"
|
||||
CI_SCRIPT='
|
||||
cmake -B build-linux -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
||||
@@ -81,18 +93,22 @@ 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"
|
||||
' run_in_container "$X64_IMAGE" -v "$OUTPUT_DIR:/out"
|
||||
|
||||
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 x86_64
|
||||
' run_in_container -v "$OUTPUT_DIR:/out"
|
||||
' run_in_container "$X64_IMAGE" -v "$OUTPUT_DIR:/out"
|
||||
fi
|
||||
|
||||
# ── Linux ARM64 build and package ────────────────────────────────────────────
|
||||
if [ "$RUN_ARM64" = true ]; then
|
||||
prepare_image "linux-arm64"
|
||||
ARM64_IMAGE="${CUSTOM_IMAGE:-${IMAGE_PREFIX}/build-linux-arm64:latest}"
|
||||
[ "$BUILD_IMAGE" = true ] && ARM64_IMAGE="${CUSTOM_IMAGE:-asteria-qt-ci-linux-arm64:latest}"
|
||||
|
||||
echo "==> build-linux-arm64"
|
||||
CI_SCRIPT='
|
||||
cmake -B build-linux-arm64 -G Ninja \
|
||||
@@ -103,14 +119,14 @@ cmake -B build-linux-arm64 -G Ninja \
|
||||
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"
|
||||
' run_in_container "$ARM64_IMAGE" -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"
|
||||
' run_in_container "$ARM64_IMAGE" -v "$OUTPUT_DIR:/out"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
+56
-25
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Run CI build/package jobs locally using podman or docker.
|
||||
# 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
|
||||
# --build-image build the CI image target(s) from Dockerfile instead of pulling prebuilt ones
|
||||
# --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
|
||||
@@ -13,8 +13,8 @@ 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="${PREBUILT_IMAGE:-registry.gitlab.com/asteria-bookreader/asteria-qt/build-env:latest}"
|
||||
IMAGE_TAG="$PREBUILT_IMAGE"
|
||||
IMAGE_PREFIX="${PREBUILT_IMAGE_PREFIX:-registry.gitlab.com/asteria-bookreader/asteria-qt}"
|
||||
CUSTOM_IMAGE=""
|
||||
BUILD_IMAGE=false
|
||||
RUN_LINUX=false
|
||||
RUN_X86_64=true
|
||||
@@ -22,9 +22,9 @@ RUN_ARM64=false
|
||||
|
||||
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 ;;
|
||||
--build-image) BUILD_IMAGE=true; shift ;;
|
||||
--image) CUSTOM_IMAGE="$2"; shift 2 ;;
|
||||
--image=*) CUSTOM_IMAGE="${1#*=}"; shift ;;
|
||||
--linux) RUN_LINUX=true; shift ;;
|
||||
--arm64) RUN_ARM64=true; shift ;;
|
||||
--only-arm64) RUN_ARM64=true; RUN_X86_64=false; shift ;;
|
||||
@@ -43,20 +43,37 @@ else
|
||||
fi
|
||||
echo "Using container runtime: $RUNTIME"
|
||||
|
||||
if [ "$BUILD_IMAGE" = true ]; then
|
||||
echo "==> Building CI image from $DOCKERFILE"
|
||||
"$RUNTIME" build \
|
||||
resolve_image_tag() {
|
||||
local target="$1"
|
||||
if [ -n "$CUSTOM_IMAGE" ]; then
|
||||
echo "$CUSTOM_IMAGE"
|
||||
elif [ "$BUILD_IMAGE" = true ]; then
|
||||
echo "asteria-qt-ci-${target}:latest"
|
||||
else
|
||||
echo "${IMAGE_PREFIX}/build-${target}:latest"
|
||||
fi
|
||||
}
|
||||
|
||||
prepare_image() {
|
||||
local target="$1"
|
||||
local image_tag
|
||||
image_tag="$(resolve_image_tag "$target")"
|
||||
if [ "$BUILD_IMAGE" = true ]; then
|
||||
echo "==> Building CI image target '$target' ($image_tag) from $DOCKERFILE"
|
||||
DOCKER_BUILDKIT=1 "$RUNTIME" build \
|
||||
--platform linux/amd64 \
|
||||
--build-arg QT_VERSION=6.12.0 \
|
||||
-t "$IMAGE_TAG" \
|
||||
--target "$target" \
|
||||
-t "$image_tag" \
|
||||
-f "$DOCKERFILE" \
|
||||
"$PROJECT_DIR"
|
||||
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
|
||||
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"
|
||||
mkdir -p "$OUTPUT_DIR"
|
||||
@@ -64,13 +81,15 @@ 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 image_tag="$1"
|
||||
shift
|
||||
local extra_args=("$@")
|
||||
"$RUNTIME" run --rm \
|
||||
--platform linux/amd64 \
|
||||
--entrypoint bash \
|
||||
-v "$PROJECT_DIR:/src-ro:ro" \
|
||||
"${extra_args[@]}" \
|
||||
"$IMAGE_TAG" \
|
||||
"$image_tag" \
|
||||
-c '
|
||||
set -euo pipefail
|
||||
cp -r /src-ro /src
|
||||
@@ -81,6 +100,9 @@ run_in_container() {
|
||||
|
||||
# ── Windows x86_64 build ─────────────────────────────────────────────────────
|
||||
if [ "$RUN_X86_64" = true ]; then
|
||||
prepare_image "windows-x86_64"
|
||||
WIN_X64_IMAGE="$(resolve_image_tag "windows-x86_64")"
|
||||
|
||||
echo "==> build-windows (x86_64)"
|
||||
CI_SCRIPT='
|
||||
PKG_CONFIG_PATH="${MINGW_SYSROOT}/lib/pkgconfig" cmake -B build-windows -G Ninja \
|
||||
@@ -91,18 +113,21 @@ PKG_CONFIG_PATH="${MINGW_SYSROOT}/lib/pkgconfig" cmake -B build-windows -G Ninja
|
||||
-DQT_HOST_PATH="${QT_LINUX_DIR}"
|
||||
cmake --build build-windows --target asteria-qt
|
||||
cp -r build-windows /out/build-windows
|
||||
' run_in_container -v "$OUTPUT_DIR:/out"
|
||||
' run_in_container "$WIN_X64_IMAGE" -v "$OUTPUT_DIR:/out"
|
||||
|
||||
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 x86_64
|
||||
' run_in_container -v "$OUTPUT_DIR:/out"
|
||||
' run_in_container "$WIN_X64_IMAGE" -v "$OUTPUT_DIR:/out"
|
||||
fi
|
||||
|
||||
# ── Windows ARM64 build (optional) ───────────────────────────────────────────
|
||||
if [ "$RUN_ARM64" = true ]; then
|
||||
prepare_image "windows-arm64"
|
||||
WIN_ARM64_IMAGE="$(resolve_image_tag "windows-arm64")"
|
||||
|
||||
echo "==> build-windows-arm64"
|
||||
CI_SCRIPT='
|
||||
PKG_CONFIG_PATH="${MINGW_ARM64_SYSROOT}/lib/pkgconfig" cmake -B build-windows-arm64 -G Ninja \
|
||||
@@ -113,36 +138,42 @@ PKG_CONFIG_PATH="${MINGW_ARM64_SYSROOT}/lib/pkgconfig" cmake -B build-windows-ar
|
||||
-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"
|
||||
' run_in_container "$WIN_ARM64_IMAGE" -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"
|
||||
' run_in_container "$WIN_ARM64_IMAGE" -v "$OUTPUT_DIR:/out"
|
||||
fi
|
||||
|
||||
# ── Linux build (optional) ───────────────────────────────────────────────────
|
||||
if [ "$RUN_LINUX" = true ]; then
|
||||
if [ "$RUN_X86_64" = true ]; then
|
||||
prepare_image "linux-x86_64"
|
||||
LINUX_X64_IMAGE="$(resolve_image_tag "linux-x86_64")"
|
||||
|
||||
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 -r build-linux /out/build-linux
|
||||
' run_in_container -v "$OUTPUT_DIR:/out"
|
||||
' run_in_container "$LINUX_X64_IMAGE" -v "$OUTPUT_DIR:/out"
|
||||
|
||||
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 x86_64
|
||||
' run_in_container -v "$OUTPUT_DIR:/out"
|
||||
' run_in_container "$LINUX_X64_IMAGE" -v "$OUTPUT_DIR:/out"
|
||||
fi
|
||||
|
||||
if [ "$RUN_ARM64" = true ]; then
|
||||
prepare_image "linux-arm64"
|
||||
LINUX_ARM64_IMAGE="$(resolve_image_tag "linux-arm64")"
|
||||
|
||||
echo "==> build-linux-arm64"
|
||||
CI_SCRIPT='
|
||||
cmake -B build-linux-arm64 -G Ninja \
|
||||
@@ -152,14 +183,14 @@ cmake -B build-linux-arm64 -G Ninja \
|
||||
-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"
|
||||
' run_in_container "$LINUX_ARM64_IMAGE" -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"
|
||||
' run_in_container "$LINUX_ARM64_IMAGE" -v "$OUTPUT_DIR:/out"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in new issue
Block a user