Port the toolkit GUI to Windows (wxMSW, cross-built with mingw-w64)
Build: the wx-rs build script chose the platform with cfg!(), which in a build script describes the build host, so a Linux-to-Windows build took the GTK path. It now reads CARGO_CFG_TARGET_*, and Windows/GNU builds through wx-config exactly like GTK, against a static wxMSW from scripts/build-wx-windows.sh. The C++ runtime is linked statically, so the .exe imports only Windows system DLLs. crates/alkane-gui/build.rs embeds an application manifest (Common Controls v6, per-monitor DPI v2, UTF-8 code page, Windows 10/11), the icon and version info. Bridge on wxMSW (patches 0007/0008): - the upstream frame's invisible "OSX key events" child sat above the UI on MSW and swallowed every click and key; it is no longer created there - light/dark is chosen before the first window (wxMSW ignores it later) and follows the Windows app mode, with dark grid rules for the data view - the generic wxDataViewCtrl gets mouse input in its inner main window, so drag-select and the per-cell / per-icon tooltips bind there (GTK keeps its native GtkTreeView paths; the icon hit-test is shared) - sizes cross the Rust/C++ boundary in DIPs (identity on GTK), so columns, icons, KPI cards and the status bar scale at 125-200 % - vector shapes go through GDI+ (anti-aliased like Cairo on GTK); selected rows use the themed list-view text colour like the native renderer - the frame never opens larger than the monitor work area; title-bar icon from the executable; upstream menu insert no longer reads UTF-8 as UTF-16 App: OS differences live in alkane_core::platform (settings in %APPDATA%\alkane-toolkit, owner-only secret files, NUL, console-less helper processes). SSH password logins use SSH_ASKPASS with the toolkit itself as the helper on every platform, replacing sshpass, which Windows lacks. Release builds are GUI-subsystem; headless modes attach to the parent console. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,22 +1,26 @@
|
||||
#!/bin/sh
|
||||
# Build the alkane-toolkit GUI for Windows (x86_64) from Linux, via mingw-w64.
|
||||
# wx-rs upstream supports MSW (it downloads and builds wx 3.2.2.1 with MSVC
|
||||
# via nmake, or links an msys2 mingw64 wx). Two supported routes:
|
||||
# Build the alkane-toolkit GUI for Windows (x86_64) on Linux by cross-compiling
|
||||
# with mingw-w64 against the vendored wxWidgets 3.3.3 (wxMSW), the same way CI
|
||||
# builds the release .exe. The result is one self-contained executable: the C++
|
||||
# runtime is linked statically and it imports only DLLs Windows itself ships.
|
||||
#
|
||||
# A) On Windows: install msys2/mingw64 wx + rust-gnu, run `cargo build
|
||||
# --release -p alkane-gui` there (wx-rs build.rs handles msys2 paths).
|
||||
# B) Cross from Linux: not automated yet - wxMSW needs the MSVC or msys2
|
||||
# toolchain; tracked as follow-up. The Rust side cross-compiles fine;
|
||||
# only the C++ bridge + wx need the Windows toolchain.
|
||||
#
|
||||
# This script documents route A and fails here if run on Linux.
|
||||
# Usage: scripts/build-gui-windows.sh [cargo build args...]
|
||||
# defaults to `--release`; e.g. `scripts/build-gui-windows.sh` or
|
||||
# `scripts/build-gui-windows.sh --profile dev`.
|
||||
# Needs: mingw-w64 (posix-threads variant), the rustup target
|
||||
# x86_64-pc-windows-gnu, and the wxMSW prefix from build-wx-windows.sh
|
||||
# (built on first use).
|
||||
set -e
|
||||
if [ "$(uname -s)" = "Linux" ]; then
|
||||
echo "Route B (Linux cross to MSW) is not automated yet."
|
||||
echo "Run scripts/build-gui-windows.sh on Windows (msys2 mingw64 + rust),"
|
||||
echo "or use CI with a Windows runner."
|
||||
exit 1
|
||||
REPO=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$REPO"
|
||||
. "$REPO/scripts/windows-cross-env.sh"
|
||||
if [ ! -x "$WX_RS_WXCONFIG" ]; then
|
||||
sh "$REPO/scripts/build-wx-windows.sh"
|
||||
fi
|
||||
cd "$(dirname -- "$0")/.."
|
||||
cargo build --release -p alkane-gui
|
||||
echo "binary: target/release/alkane-toolkit.exe"
|
||||
rustup target list --installed 2>/dev/null | grep -qx "$ALKANE_WIN_TARGET" ||
|
||||
rustup target add "$ALKANE_WIN_TARGET"
|
||||
[ "$#" -gt 0 ] || set -- --release
|
||||
cargo build --offline --target "$ALKANE_WIN_TARGET" -p alkane-gui "$@"
|
||||
TDIR=$(cargo metadata --no-deps --format-version 1 --offline 2>/dev/null \
|
||||
| tr ',' '\n' | grep -o '"target_directory":"[^"]*"' | head -1 | cut -d'"' -f4)
|
||||
echo "binary: ${TDIR:-$REPO/target}/$ALKANE_WIN_TARGET/<profile>/alkane-toolkit.exe"
|
||||
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
# Cross-build the vendored wxWidgets 3.3.3 for Windows (wxMSW, x86_64, static,
|
||||
# monolithic) from Linux with mingw-w64. Mirrors build-wx-linux.sh: the repo
|
||||
# tree stays pristine, the build lives in ~/.cache/wxbuild, and the result is a
|
||||
# prefix whose bin/wx-config the wx-rs build script reads (WX_RS_WXCONFIG).
|
||||
#
|
||||
# Every third-party library wx needs is the copy bundled in the wx source tree
|
||||
# ("builtin"), so the prefix needs nothing from the build host and the final
|
||||
# .exe needs no DLLs beyond the ones Windows itself ships. TIFF and WebP are
|
||||
# off: the app never loads either format.
|
||||
#
|
||||
# Needs: mingw-w64 (the posix-threads g++ variant), make.
|
||||
set -e
|
||||
REPO=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
SRC="$REPO/thirdparty/wxwidgets/wxWidgets-3.3.3"
|
||||
HOST=x86_64-w64-mingw32
|
||||
BUILD="$HOME/.cache/wxbuild/wxWidgets-3.3.3-mingw"
|
||||
PREFIX="${WX_WINDOWS_PREFIX:-$HOME/.cache/wx-3.3.3-mingw}"
|
||||
# std::thread/std::mutex need the posix thread model; Debian's default
|
||||
# x86_64-w64-mingw32-g++ alternative is the win32 model.
|
||||
CC="${WX_WINDOWS_CC:-$HOST-gcc-posix}"
|
||||
CXX="${WX_WINDOWS_CXX:-$HOST-g++-posix}"
|
||||
command -v "$CXX" >/dev/null || { echo "$CXX not found (apt install mingw-w64)"; exit 1; }
|
||||
|
||||
cleanup_wx_build() {
|
||||
python3 - "$BUILD" "$HOME/.cache/wxbuild" <<'PY'
|
||||
from pathlib import Path
|
||||
import shutil
|
||||
import sys
|
||||
|
||||
build, parent = map(Path, sys.argv[1:])
|
||||
if (build.name != "wxWidgets-3.3.3-mingw" or build.parent != parent
|
||||
or build.is_symlink() or parent.is_symlink()):
|
||||
raise SystemExit("refusing unsafe wxWidgets build cleanup path")
|
||||
if build.is_dir():
|
||||
shutil.rmtree(build)
|
||||
PY
|
||||
}
|
||||
trap cleanup_wx_build 0
|
||||
[ -d "$SRC" ] || { echo "thirdparty wxWidgets tree missing"; exit 1; }
|
||||
[ -d "$BUILD" ] || { mkdir -p "$HOME/.cache/wxbuild"; cp -r "$SRC" "$BUILD"; }
|
||||
chmod +x "$BUILD/configure" "$BUILD/config.guess" "$BUILD/config.sub" "$BUILD/install-sh" 2>/dev/null || true
|
||||
mkdir -p "$BUILD/build-msw"
|
||||
cd "$BUILD/build-msw"
|
||||
# --enable-unicode is the 3.3 default. wxUSE_RC_MANIFEST/DPI awareness are
|
||||
# handled by the application's own resource script (crates/alkane-gui/build.rs),
|
||||
# not here, so the library stays policy-free.
|
||||
sh ../configure --host="$HOST" --build="$(sh ../config.guess)" \
|
||||
--prefix="$PREFIX" CC="$CC" CXX="$CXX" \
|
||||
--disable-shared --enable-monolithic --with-msw \
|
||||
--with-opengl=no --disable-stc --disable-tests --disable-webview \
|
||||
--with-libpng=builtin --with-libjpeg=builtin --with-regex=builtin \
|
||||
--with-zlib=builtin --with-expat=builtin \
|
||||
--without-libtiff --without-libwebp --without-liblzma
|
||||
make -j"${WX_BUILD_JOBS:-$(nproc)}"
|
||||
make install
|
||||
ls "$PREFIX"/lib/libwx_mswu-3.3-"$HOST".a >/dev/null
|
||||
echo "installed: $PREFIX ($("$PREFIX/bin/wx-config" --version) $("$PREFIX/bin/wx-config" --selected-config))"
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
# Headless UI workflow self-test of the WINDOWS build, under Wine on a private
|
||||
# Xvfb display: the same ALKANE_SELFTEST check as scripts/ui-selftest.sh (bench
|
||||
# fixtures rendered through the real wxMSW widgets, read back, and compared),
|
||||
# run against alkane-toolkit.exe. CI runs this on every build; the native
|
||||
# Windows smoke job (.gitea/workflows/windows-native.yml) repeats it on real
|
||||
# Windows.
|
||||
#
|
||||
# Usage: scripts/ui-selftest-windows.sh [alkane-toolkit.exe]
|
||||
# defaults to the cross-built release binary in the cargo target dir.
|
||||
set -u
|
||||
REPO=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
EXE="${1:-}"
|
||||
if [ -z "$EXE" ]; then
|
||||
sh "$REPO/scripts/build-gui-windows.sh" || exit 3
|
||||
TDIR=$(cd "$REPO" && cargo metadata --no-deps --format-version 1 --offline 2>/dev/null \
|
||||
| tr ',' '\n' | grep -o '"target_directory":"[^"]*"' | head -1 | cut -d'"' -f4)
|
||||
EXE="${TDIR:-$REPO/target}/x86_64-pc-windows-gnu/release/alkane-toolkit.exe"
|
||||
fi
|
||||
[ -f "$EXE" ] || { echo "executable not found: $EXE" >&2; exit 3; }
|
||||
# xvfb-run picks a free display and cleans it up; Wine needs an X server for
|
||||
# the window even though the self-test never shows it to anyone.
|
||||
xvfb-run -a -s '-screen 0 1280x850x24' \
|
||||
env ALKANE_SELFTEST=1 sh "$REPO/scripts/wine-run.sh" "$EXE"
|
||||
RC=$?
|
||||
echo "== ui-selftest-windows exit=$RC =="
|
||||
exit "$RC"
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
# shellcheck shell=sh
|
||||
# Toolchain environment for cross-building the toolkit for Windows
|
||||
# (x86_64-pc-windows-gnu) on Linux. One definition, used by
|
||||
# scripts/build-gui-windows.sh locally and by the CI Windows job:
|
||||
#
|
||||
# . scripts/windows-cross-env.sh # export into this shell
|
||||
# sh scripts/windows-cross-env.sh --github-env # append to $GITHUB_ENV
|
||||
#
|
||||
# WX_WINDOWS_PREFIX selects the wxMSW prefix built by build-wx-windows.sh.
|
||||
# `cargo test --target x86_64-pc-windows-gnu` runs the test .exe files through
|
||||
# scripts/wine-run.sh, so the Windows build is unit-tested on every Linux host.
|
||||
# The posix-threads mingw variants are required: libstdc++'s std::thread and
|
||||
# the wx build both use them, and mixing in the win32-thread variant at link
|
||||
# time fails on missing pthread symbols.
|
||||
WX_WINDOWS_PREFIX="${WX_WINDOWS_PREFIX:-$HOME/.cache/wx-3.3.3-mingw}"
|
||||
ALKANE_WIN_TARGET=x86_64-pc-windows-gnu
|
||||
# Sourced scripts cannot rely on $0, so locate the checkout through git.
|
||||
ALKANE_REPO="${ALKANE_REPO:-$(git rev-parse --show-toplevel)}"
|
||||
|
||||
_alkane_win_env() {
|
||||
cat <<EOF
|
||||
WX_WINDOWS_PREFIX=$WX_WINDOWS_PREFIX
|
||||
WX_RS_WXCONFIG=$WX_WINDOWS_PREFIX/bin/wx-config
|
||||
ALKANE_WIN_TARGET=$ALKANE_WIN_TARGET
|
||||
CC_x86_64_pc_windows_gnu=x86_64-w64-mingw32-gcc-posix
|
||||
CXX_x86_64_pc_windows_gnu=x86_64-w64-mingw32-g++-posix
|
||||
AR_x86_64_pc_windows_gnu=x86_64-w64-mingw32-ar
|
||||
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc-posix
|
||||
WINDRES=x86_64-w64-mingw32-windres
|
||||
CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER=$ALKANE_REPO/scripts/wine-run.sh
|
||||
EOF
|
||||
}
|
||||
|
||||
if [ "${1:-}" = "--github-env" ]; then
|
||||
_alkane_win_env >> "${GITHUB_ENV:?GITHUB_ENV is required}"
|
||||
else
|
||||
eval "$(_alkane_win_env | sed 's/^/export /')"
|
||||
fi
|
||||
Executable
+20
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
# Cargo target runner for x86_64-pc-windows-gnu: run a Windows .exe under Wine.
|
||||
# Set via CARGO_TARGET_X86_64_PC_WINDOWS_GNU_RUNNER (scripts/windows-cross-env.sh).
|
||||
# A private, reusable Wine prefix keeps runs isolated from any desktop Wine
|
||||
# setup and avoids re-creating the prefix (~10 s) for every test binary.
|
||||
set -e
|
||||
export WINEPREFIX="${ALKANE_WINEPREFIX:-$HOME/.cache/alkane-wine}"
|
||||
export WINEDEBUG="${WINEDEBUG:--all}"
|
||||
# No Wine menu entries/file associations, no Gecko/Mono install prompts.
|
||||
export WINEDLLOVERRIDES="${WINEDLLOVERRIDES:-winemenubuilder.exe=d;mscoree=d;mshtml=d}"
|
||||
WINE="${WINE:-$(command -v wine64 || command -v wine)}"
|
||||
if [ ! -f "$WINEPREFIX/system.reg" ]; then
|
||||
mkdir -p "$WINEPREFIX"
|
||||
# The registry (system.reg, the "prefix is ready" marker) is only written
|
||||
# when the wine server shuts down, so finish the boot explicitly.
|
||||
"$WINE" wineboot --init >/dev/null 2>&1 || true
|
||||
"$WINE" wineboot --shutdown >/dev/null 2>&1 || true
|
||||
wineserver -w 2>/dev/null || true
|
||||
fi
|
||||
exec "$WINE" "$@"
|
||||
Reference in New Issue
Block a user