From 22c842d5e3e422e359f7fc033d9133a3d269be44 Mon Sep 17 00:00:00 2001 From: mirivlad Date: Mon, 13 Jul 2026 21:46:40 +0800 Subject: [PATCH] build: add Windows plugin packages --- .gitignore | 1 + README.md | 14 ++++++++++ scripts/build-windows.sh | 52 +++++++++++++++++++++++++++++++++++ scripts/test-build-windows.sh | 19 +++++++++++++ 4 files changed, 86 insertions(+) create mode 100755 scripts/build-windows.sh create mode 100755 scripts/test-build-windows.sh diff --git a/.gitignore b/.gitignore index 914cbdd..e70efd4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ dist/ +dist-windows/ release/ node_modules/ # compiled backend binaries (built from source) diff --git a/README.md b/README.md index e54b088..62b4811 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,20 @@ cd ../verstak-desktop ./scripts/install-dev-plugins.sh ``` +## Windows test packages from Linux + +Install a MinGW cross-compiler, then build a separate Windows amd64 package +tree: + +```bash +sudo apt install gcc-mingw-w64-x86-64 +./scripts/build-windows.sh +``` + +The result is `dist-windows/`. Go sidecars, when a plugin has one, are emitted +as `backend/.exe`; frontends and manifests are the same packaged +files used on Linux. This is a local test output and is not a GitHub Release. + ## Alpha behaviour - Browser Inbox archives processed captures and can restore them; permanent diff --git a/scripts/build-windows.sh b/scripts/build-windows.sh new file mode 100755 index 0000000..1a856d6 --- /dev/null +++ b/scripts/build-windows.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +WINDOWS_DIST="${VERSTAK_WINDOWS_PLUGIN_DIST:-$ROOT/dist-windows}" +WINDOWS_CC="${VERSTAK_WINDOWS_CC:-x86_64-w64-mingw32-gcc}" +GO_BIN="${GO_BIN:-go}" + +if ! command -v "$WINDOWS_CC" >/dev/null; then + echo "Windows cross-compiler not found: $WINDOWS_CC" >&2 + echo "Install x86_64-w64-mingw32-gcc (for example: sudo apt install gcc-mingw-w64-x86-64)." >&2 + exit 1 +fi +if ! command -v "$GO_BIN" >/dev/null; then + echo "go is required to build Windows plugin backends" >&2 + exit 1 +fi + +cd "$ROOT" +echo "=== verstak official plugins Windows amd64 build ===" + +# Reuse the canonical frontend and manifest packager, then replace every Go +# sidecar with its Windows executable in a separate dist-windows tree. +./scripts/build.sh +rm -rf "$WINDOWS_DIST" +mkdir -p "$WINDOWS_DIST" +cp -R "$ROOT/dist/." "$WINDOWS_DIST/" + +backend_count=0 +for plugin_dir in "$ROOT"/plugins/*/; do + [[ -d "$plugin_dir" ]] || continue + plugin_name="$(basename "$plugin_dir")" + backend_dir="$plugin_dir/backend" + [[ -d "$backend_dir" ]] || continue + if [[ ! -f "$backend_dir/go.mod" && ! -f "$backend_dir/main.go" ]]; then + continue + fi + + package_backend="$WINDOWS_DIST/$plugin_name/backend" + rm -rf "$package_backend" + mkdir -p "$package_backend" + echo " → Windows backend: $plugin_name.exe" + ( + cd "$backend_dir" + GOOS=windows GOARCH=amd64 CGO_ENABLED=1 CC="$WINDOWS_CC" \ + "$GO_BIN" build -o "$package_backend/$plugin_name.exe" . + ) + backend_count=$((backend_count + 1)) +done + +echo "Windows plugin packages: $WINDOWS_DIST" +echo "Windows backends built: $backend_count" diff --git a/scripts/test-build-windows.sh b/scripts/test-build-windows.sh new file mode 100755 index 0000000..1a88bdb --- /dev/null +++ b/scripts/test-build-windows.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$(cd "$(dirname "$0")/.." && pwd)" +BUILDER="$ROOT/scripts/build-windows.sh" + +if [[ ! -x "$BUILDER" ]]; then + echo "Windows plugin builder is missing or not executable: $BUILDER" >&2 + exit 1 +fi + +bash -n "$BUILDER" +grep -Fq 'GOOS=windows' "$BUILDER" +grep -Fq 'GOARCH=amd64' "$BUILDER" +grep -Fq 'dist-windows' "$BUILDER" +grep -Fq '.exe' "$BUILDER" +grep -Fq 'x86_64-w64-mingw32-gcc' "$BUILDER" + +echo "Windows plugin build script contract passed"