- Add `build-windows-arm64` and `package-windows-arm64` stages to `.gitlab-ci.yml` and wire download links to wiki updates - Create `scripts/mingw-w64-arm64-toolchain.cmake` targeting `Windows` / `aarch64` with LLVM-MinGW - Update `docker/Dockerfile.build` with LLVM-MinGW toolchain, MSYS2 Qt 6.10 ARM64 packages, and ARM64 cross-compiled static libraries (libiconv, uchardet, zlib, minizip, libarchive) - Isolate GCC x86_64 and LLVM-MinGW ARM64 toolchains in `scripts/mingw-w64-toolchain.cmake` and PATH configuration - Refactor `packaging/package-windows.sh` to package both x86_64 and ARM64 runtime DLLs and support MSYS2 plugin/QML directory layouts - Update `scripts/test-ci-windows.sh` with `--arm64`, `--only-arm64`, `--image`, and local image detection - Guard `-mwindows` link flag with `if(MINGW)` in `CMakeLists.txt` - Document Windows ARM64 build targets and instructions in `AGENTS.md` and `README.md`
146 lines
5.3 KiB
Bash
Executable File
146 lines
5.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# Run CI build/package jobs locally using podman or docker.
|
|
# Usage: test-ci-windows.sh [--build-image] [--linux] [--arm64]
|
|
# --build-image build the CI image from Dockerfile instead of pulling the prebuilt one
|
|
# --linux also run build-linux + package-linux in addition to Windows jobs
|
|
# --arm64 also run build-windows-arm64 + package-windows-arm64
|
|
set -euo pipefail
|
|
|
|
export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
OUTPUT_DIR="$PROJECT_DIR/ci-output"
|
|
DOCKERFILE="$PROJECT_DIR/docker/Dockerfile.build"
|
|
PREBUILT_IMAGE="${PREBUILT_IMAGE:-registry.gitlab.com/asteria-bookreader/asteria-qt/build-env:latest}"
|
|
IMAGE_TAG="$PREBUILT_IMAGE"
|
|
BUILD_IMAGE=false
|
|
RUN_LINUX=false
|
|
RUN_X86_64=true
|
|
RUN_ARM64=false
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
case "$1" in
|
|
--build-image) BUILD_IMAGE=true; IMAGE_TAG="asteria-qt-ci-local:latest"; shift ;;
|
|
--image) IMAGE_TAG="$2"; shift 2 ;;
|
|
--image=*) IMAGE_TAG="${1#*=}"; shift ;;
|
|
--linux) RUN_LINUX=true; shift ;;
|
|
--arm64) RUN_ARM64=true; shift ;;
|
|
--only-arm64) RUN_ARM64=true; RUN_X86_64=false; shift ;;
|
|
*) echo "Unknown argument: $1"; exit 1 ;;
|
|
esac
|
|
done
|
|
|
|
# Detect container runtime
|
|
if command -v podman &>/dev/null; then
|
|
RUNTIME=podman
|
|
elif command -v docker &>/dev/null; then
|
|
RUNTIME=docker
|
|
else
|
|
echo "ERROR: neither podman nor docker found in PATH"
|
|
exit 1
|
|
fi
|
|
echo "Using container runtime: $RUNTIME"
|
|
|
|
if [ "$BUILD_IMAGE" = true ]; then
|
|
echo "==> Building CI image from $DOCKERFILE"
|
|
"$RUNTIME" build \
|
|
--platform linux/amd64 \
|
|
--build-arg QT_VERSION=6.10.3 \
|
|
-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
|
|
|
|
rm -rf "$OUTPUT_DIR"
|
|
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 \
|
|
--platform linux/amd64 \
|
|
--entrypoint bash \
|
|
-v "$PROJECT_DIR:/src-ro:ro" \
|
|
"${extra_args[@]}" \
|
|
"$IMAGE_TAG" \
|
|
-c '
|
|
set -euo pipefail
|
|
cp -r /src-ro /src
|
|
cd /src
|
|
'"$CI_SCRIPT"'
|
|
'
|
|
}
|
|
|
|
# ── Windows x86_64 build ─────────────────────────────────────────────────────
|
|
if [ "$RUN_X86_64" = true ]; then
|
|
echo "==> build-windows (x86_64)"
|
|
CI_SCRIPT='
|
|
PKG_CONFIG_PATH="${MINGW_SYSROOT}/lib/pkgconfig" cmake -B build-windows -G Ninja \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_TOOLCHAIN_FILE=/src/scripts/mingw-w64-toolchain.cmake \
|
|
-DCMAKE_PREFIX_PATH="${QT_WINDOWS_DIR};${MINGW_SYSROOT}" \
|
|
-DCMAKE_FIND_ROOT_PATH="${QT_WINDOWS_DIR};${MINGW_SYSROOT}" \
|
|
-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"
|
|
|
|
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"
|
|
fi
|
|
|
|
# ── Windows ARM64 build (optional) ───────────────────────────────────────────
|
|
if [ "$RUN_ARM64" = true ]; then
|
|
echo "==> build-windows-arm64"
|
|
CI_SCRIPT='
|
|
PKG_CONFIG_PATH="${MINGW_ARM64_SYSROOT}/lib/pkgconfig" cmake -B build-windows-arm64 -G Ninja \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_TOOLCHAIN_FILE=/src/scripts/mingw-w64-arm64-toolchain.cmake \
|
|
-DCMAKE_PREFIX_PATH="${QT_WINDOWS_ARM64_DIR};${MINGW_ARM64_SYSROOT}" \
|
|
-DCMAKE_FIND_ROOT_PATH="${QT_WINDOWS_ARM64_DIR};${MINGW_ARM64_SYSROOT}" \
|
|
-DQT_HOST_PATH="${QT_LINUX_DIR}"
|
|
cmake --build build-windows-arm64 --target asteria-qt
|
|
cp -r build-windows-arm64 /out/build-windows-arm64
|
|
' run_in_container -v "$OUTPUT_DIR:/out"
|
|
|
|
echo "==> package-windows-arm64"
|
|
CI_SCRIPT='
|
|
cp -r /out/build-windows-arm64 build-windows-arm64
|
|
chmod +x packaging/package-windows.sh
|
|
packaging/package-windows.sh build-windows-arm64 "${QT_WINDOWS_ARM64_DIR}" "${MINGW_ARM64_SYSROOT}" /out arm64
|
|
' run_in_container -v "$OUTPUT_DIR:/out"
|
|
fi
|
|
|
|
# ── Linux build (optional) ───────────────────────────────────────────────────
|
|
if [ "$RUN_LINUX" = true ]; then
|
|
echo "==> build-linux"
|
|
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/
|
|
' run_in_container -v "$OUTPUT_DIR:/out"
|
|
|
|
echo "==> package-linux"
|
|
CI_SCRIPT='
|
|
cp /out/asteria-qt build-linux/asteria-qt
|
|
chmod +x packaging/package-linux.sh
|
|
packaging/package-linux.sh build-linux "${QT_LINUX_DIR}" /out
|
|
' run_in_container -v "$OUTPUT_DIR:/out"
|
|
fi
|
|
|
|
echo ""
|
|
echo "==> Done. Artifacts in $OUTPUT_DIR/"
|
|
ls -lh "$OUTPUT_DIR/"
|