#!/usr/bin/env bash # SPDX-License-Identifier: MIT # Every Windows CI step in one place, so verify (PRs), the main release and the # next-branch candidates build and test the .exe the same way: # # windows-ci.sh toolchain mingw-w64 + Wine + the rustup target # windows-ci.sh clippy clippy for x86_64-pc-windows-gnu, -D warnings # windows-ci.sh build release alkane-toolkit.exe # windows-ci.sh test all unit tests, run under Wine # windows-ci.sh selftest headless UI self-test under Wine + Xvfb # windows-ci.sh package VERSION dist/alkane-toolkit-vVERSION-windows-x86_64.zip # windows-ci.sh test-bundle dist/alkane-toolkit-windows-tests.zip (for # the native Windows job) # # The wxMSW prefix comes from the CI image or ci/ensure-wx-prefix.sh windows. set -euo pipefail cd "$(git rev-parse --show-toplevel)" export WX_WINDOWS_PREFIX="${WX_WINDOWS_PREFIX:-/root/.cache/wx-3.3.3-mingw}" export ALKANE_WINEPREFIX="${ALKANE_WINEPREFIX:-/root/.cache/alkane-wine}" # shellcheck source=../scripts/windows-cross-env.sh . scripts/windows-cross-env.sh target="$ALKANE_WIN_TARGET" out_dir="${CARGO_TARGET_DIR:-target}" exe="$out_dir/$target/release/alkane-toolkit.exe" # The GUI crate's tests link wx and some create windows; Wine wants a display. headless() { xvfb-run -a -s '-screen 0 1280x850x24' "$@"; } case "${1:-}" in toolchain) bash ci/ensure-build-deps.sh windows rustup target list --installed | grep -qx "$target" || rustup target add "$target" ;; clippy) rustup component add clippy >/dev/null 2>&1 || true cargo clippy -p alkane-gui --no-deps --release --bins --target "$target" --offline -- -D warnings cargo clippy --workspace --exclude alkane-gui --exclude wx-rs --all-targets \ --target "$target" --offline -- -D warnings ;; build) cargo build --release -p alkane-gui --target "$target" --offline # One self-contained .exe: any toolchain DLL import would fail on a clean # Windows machine, so refuse to ship one. if x86_64-w64-mingw32-objdump -p "$exe" | grep -iE 'DLL Name: (libstdc|libgcc|libwinpthread)'; then echo "alkane-toolkit.exe imports a mingw runtime DLL" >&2 exit 1 fi ;; test) headless cargo test --workspace --exclude wx-rs --target "$target" --offline 2>&1 \ | tee tests-windows.txt ;; selftest) bash scripts/ui-selftest-windows.sh "$exe" ;; package) python3 ci/package-windows.py release "${2:?usage: windows-ci.sh package VERSION}" "$exe" dist ;; test-bundle) mkdir -p dist cargo test --workspace --exclude wx-rs --target "$target" --offline --no-run \ --message-format=json > "$out_dir/windows-tests.json" python3 ci/package-windows.py tests "$out_dir/windows-tests.json" \ dist/alkane-toolkit-windows-tests.zip ;; *) sed -n '3,16p' "$0" >&2 exit 2 ;; esac