From 01d133bb13b7083ebf7f31ac401d33394fe7e005 Mon Sep 17 00:00:00 2001 From: Willie Date: Thu, 26 Feb 2026 00:38:30 +0800 Subject: [PATCH] feat(build): add Windows ARM64 cross-compile script For testing on UTM Windows VMs. Scans common shared folder locations and presents interactive picker when multiple found. make build-windows SHARED=~/Downloads mise run build:windows ~/Downloads --- Makefile | 5 +++- mise.toml | 4 ++++ scripts/build-windows.sh | 50 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100755 scripts/build-windows.sh diff --git a/Makefile b/Makefile index 6e2fb2015..2bf1c3b9a 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: help build build-meta run test test-unit test-int test-docker test-docker-online test-redteam test-redteam-signal test-redteam-rules-signal playground playground-down dev-docker dev-docker-down docker-build docker-build-multiarch lint fmt fmt-check check install clean ui-install ui-build ui-dev build-all +.PHONY: help build build-meta build-windows run test test-unit test-int test-docker test-docker-online test-redteam test-redteam-signal test-redteam-rules-signal playground playground-down dev-docker dev-docker-down docker-build docker-build-multiarch lint fmt fmt-check check install clean ui-install ui-build ui-dev build-all help: @echo "Common tasks:" @@ -35,6 +35,9 @@ build: build-meta: ./scripts/build.sh +build-windows: + ./scripts/build-windows.sh $(SHARED) + run: build ./bin/skillshare --help diff --git a/mise.toml b/mise.toml index afb7976a6..21abab314 100644 --- a/mise.toml +++ b/mise.toml @@ -40,6 +40,10 @@ run = "mkdir -p bin && go build -o bin/skillshare ./cmd/skillshare" description = "Build with version metadata" run = "./scripts/build.sh" +[tasks."build:windows"] +description = "Cross-compile for Windows ARM64 and copy to shared folder" +run = "./scripts/build-windows.sh ${1:-}" + [tasks.run] description = "Run skillshare help using the local binary" depends = ["build"] diff --git a/scripts/build-windows.sh b/scripts/build-windows.sh new file mode 100755 index 000000000..26125764e --- /dev/null +++ b/scripts/build-windows.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Cross-compile skillshare for Windows ARM64 and copy to UTM shared folder. +# Usage: ./scripts/build-windows.sh [shared_folder] +set -euo pipefail + +if [ -n "${1:-}" ]; then + SHARED="$1" +else + # Scan common shared folder locations + candidates=() + for dir in "$HOME/Downloads" "$HOME/Public" "$HOME/Desktop" "$HOME/Shared"; do + [ -d "$dir" ] && candidates+=("$dir") + done + + # Also check UTM shared mount points (VirtioFS typically shows up here) + for dir in /Volumes/Shared* /Volumes/UTM*; do + [ -d "$dir" ] 2>/dev/null && candidates+=("$dir") + done + + if [ ${#candidates[@]} -eq 0 ]; then + echo "✗ No shared folder found. Usage: $0 " >&2 + exit 1 + elif [ ${#candidates[@]} -eq 1 ]; then + SHARED="${candidates[0]}" + else + echo "Select shared folder:" + for i in "${!candidates[@]}"; do + printf " %d) %s\n" $((i + 1)) "${candidates[$i]}" + done + printf " q) Cancel\n" + printf "> " + read -r choice + case "$choice" in + q|Q) echo "Cancelled."; exit 0 ;; + *) SHARED="${candidates[$((choice - 1))]}" ;; + esac + fi +fi + +if [ ! -d "$SHARED" ]; then + echo "✗ Directory not found: $SHARED" >&2 + exit 1 +fi + +echo "Building Windows ARM64..." +GOOS=windows GOARCH=arm64 go build -o bin/skillshare-arm64.exe ./cmd/skillshare/ + +cp bin/skillshare-arm64.exe "$SHARED/skillshare.exe" +echo "✓ $(file bin/skillshare-arm64.exe | cut -d: -f2 | xargs)" +echo "→ $SHARED/skillshare.exe ($(du -h "$SHARED/skillshare.exe" | cut -f1 | xargs))"