Files
arcrun-collector/cmd/arcrun-tray/build-windows.sh
T
Leo 1b58cd1a35 fix(t72): build-windows.sh 補版本注入(Mac 有、Windows 漏了)+tray go.mod tidy
實測抓到:Windows 版編出來 v0.10.0 命中 0——版本注入只加在 build-mac.sh,
Windows 那支漏了(我今天改的那份在 detached worktree,沒進分支)。

v0.10.0 兩平台實測:
  Mac  zip 15.92MB|托盤 21.15MB(strip)|collector 14.46MB(含 PDFium)
  Win  zip 16.86MB|tray 22.40MB|collector 15.15MB
  兩者皆 < jsDelivr 20MB
  指紋全中:v0.10.0/版本列/結束 Arcrun RAG/PDF 打不開(轉檔層)

順帶修:tray go.mod 需 tidy 才編得過(合併後又被覆蓋,撞了兩次)。
2026-07-27 21:17:50 +08:00

64 lines
3.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# build-windows.sh — 打包 Arcrun RAG 托盤(Windows 未簽章版,daemon-beta t72)。
#
# 🎯 這支腳本的重點:**在 Mac 上就能交叉編譯出 Windows 版**,不需要 Windows 機器、
# 不需要 Docker、不需要 fyne-cross。條件只有一個——裝 mingw-w64。
# (這推翻了先前「fyne GUI 編不了 CGo+GL → 歸屬真機」的假設;2026-07-27 本機實測通過。)
#
# 前置(一次就好):
# brew install mingw-w64 # 提供 x86_64-w64-mingw32-gcc
#
# 用法:
# cd collector/cmd/arcrun-tray && bash build-windows.sh
# 產物:dist-windows/ArcrunRAG-win-unsigned.zip(含 arcrun-tray.exe arcrun-collector.exe
#
# ⚠️ 誠實界定:**本腳本只證明「編得出來」,沒證明「跑起來對」**。
# 托盤 icon 會不會出現、選資料夾對話框、SmartScreen 實際攔截行為,
# **只有真的在 Windows 上跑才驗得到**——那一步歸 leo/真機。
set -euo pipefail
cd "$(dirname "$0")"
# 版本編號(leo 2026-07-27:「daemon 要加上版本編號」)——與 build-mac.sh 同一套。
# 沒版本號時只能靠 shasum 對帳,使用者根本做不到(見 daemon-beta tasks t63)。
VERSION="${VERSION:-$(git describe --tags --always --dirty 2>/dev/null || echo dev)}"
BUILD_TIME="$(date '+%Y%m%d-%H%M')"
LDFLAGS_VER="-X main.version=${VERSION} -X main.buildTime=${BUILD_TIME}"
echo "🏷 版本:${VERSION}build ${BUILD_TIME}"
OUT="dist-windows"
CC_WIN="${CC_WIN:-x86_64-w64-mingw32-gcc}"
echo "① 檢查交叉編譯器"
if ! command -v "$CC_WIN" >/dev/null 2>&1; then
echo "❌ 找不到 $CC_WIN。先跑:brew install mingw-w64" >&2
exit 1
fi
echo " $($CC_WIN --version | head -1)"
rm -rf "$OUT" && mkdir -p "$OUT"
echo "② 編 collector.exe(純 stdlibCGO_ENABLED=0 即可)"
( cd ../.. && CGO_ENABLED=0 GOOS=windows GOARCH=amd64 \
go build -ldflags "-s -w" -o "cmd/arcrun-tray/$OUT/arcrun-collector.exe" . )
echo "③ 編托盤 GUIfyneCGo+GL,走 mingw-H windowsgui=不彈黑色命令列視窗)"
CGO_ENABLED=1 GOOS=windows GOARCH=amd64 CC="$CC_WIN" \
go build -ldflags "-H windowsgui -s -w ${LDFLAGS_VER}" -o "$OUT/arcrun-tray.exe" .
echo "④ 打包 zip"
( cd "$OUT" && zip -9 -q ArcrunRAG-win-unsigned.zip arcrun-tray.exe arcrun-collector.exe )
echo
echo "✅ 完成:$OUT/ArcrunRAG-win-unsigned.zip"
ls -lh "$OUT"/*.exe "$OUT"/*.zip | awk '{print " "$9" "$5}'
echo
echo "📏 2026-07-27 本機實測基準(差太多就是哪裡不對):"
echo " arcrun-tray.exe ~23.5 MB(未加 -s -w 是 ~40.8 MB"
echo " arcrun-collector.exe ~6.5 MB"
echo " zip 合計 ~13.9 MB ← **在 jsDelivr 20MB 上限內**Mac 版 21MB 超標故走 GitHub raw"
echo
echo "🔬 驗法(這台機器上驗得到的部分):"
echo " file $OUT/arcrun-tray.exe → 應為 'PE32+ executable (GUI) x86-64, for MS Windows'"
echo " file $OUT/arcrun-collector.exe → 應為 'PE32+ executable (console) x86-64'"
echo "⛔ 驗不到、必須真 Windows 機器的部分:托盤 icon 顯示/選資料夾對話框/SmartScreen 實際行為。"