#!/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))"