Files
arcrun-collector/cmd/arcrun-tray/build-mac.sh
T
Leo 1c48d58789 fix(t72/t63): build-mac.sh 加 -s -w——Mac 版掉進 jsDelivr 20MB 內,免拆檔
真兇:fyne package 內部自己 go build,吃不到 -ldflags,產出含符號表+DWARF 的胖執行檔。
解:②b 用 -s -w 重編托盤覆蓋回 bundle;collector 也一併 strip。

實測(從乾淨狀態重跑 build-mac.sh):
  托盤   28.6MB → 21.1MB
  整包zip 21.1MB → 12.43MB  ← 遠低於 jsDelivr 20MB 上限
  功能指紋 結束 Arcrun RAG=1 / 連上知識庫=1(未掉功能)
  codesign -v 通過

影響:此前 Mac 版超 20MB,jsDelivr 直接回 File size exceeded,只能走 raw;
現在可走 CDN,且**免除原本要拆檔(tray/collector 分開)的工程**。
Windows 版 13MB 本來就在限內,不受影響。

未驗:真機執行行為(托盤 icon/選資料夾)——strip 不影響邏輯但仍需真機確認。
2026-07-27 19:31:30 +08:00

44 lines
2.4 KiB
Bash
Executable File
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-mac.sh — 打包 Arcrun RAG 托盤 appdaemon-beta t7/t8,真機執行)。
#
# leo 07-24 裁決:**選單列托盤 icon 是唯一指示器,不佔 Dock**——
# fyne 預設 bundle 會出現 Dock icon,打包後把 LSUIElement=true 寫進 Info.plist 即隱。
#
# 用法(真機、需 Xcode CLT):
# cd collector/cmd/arcrun-tray && bash build-mac.sh
# 產物:Arcrun RAG.app(含同綑 arcrun-collector)。簽章/公證另行(見 README)。
set -euo pipefail
cd "$(dirname "$0")"
echo "① 編 collector(同綑執行檔)"
( cd ../.. && go build -ldflags "-s -w" -o "cmd/arcrun-tray/arcrun-collector" . )
echo "② fyne package"
go run fyne.io/fyne/v2/cmd/fyne@latest package -os darwin -icon icon.png -name "Arcrun RAG" -appID dev.arcrun.rag.tray
# ②b 用 -s -w 重編托盤覆蓋回 bundle2026-07-27t72/t63)。
# 為什麼:`fyne package` 內部自己 go build,吃不到 -ldflags,產出含符號表與 DWARF 的胖執行檔。
# 實測(本機):托盤 28.6MB → 21.3MB**整包 zip 21.1MB → 14.65MB**
# **掉進 jsDelivr 單檔 20MB 上限內**(此前 Mac 版超標,jsDelivr 直接回
# "File size exceeded the configured limit of 20 MB.",只能走 rawWindows 版 13MB 無此問題)。
# ⇒ 這一步讓 Mac 版也能走 CDN,且**免除拆檔工程**。功能指紋與簽章實測皆不受影響。
echo "②b strip 重編托盤(-s -w;為了掉進 jsDelivr 20MB 線內)"
go build -ldflags "-s -w" -o "$(ls -d *.app 2>/dev/null | head -1)/Contents/MacOS/arcrun-tray" . 2>/dev/null \
|| go build -ldflags "-s -w" -o "Arcrun RAG.app/Contents/MacOS/arcrun-tray" .
APP="Arcrun RAG.app"
PLIST="$APP/Contents/Info.plist"
echo "③ LSUIElement=true(托盤唯一指示器,隱 Dock icon——leo 07-24 裁決)"
/usr/libexec/PlistBuddy -c "Add :LSUIElement bool true" "$PLIST" 2>/dev/null \
|| /usr/libexec/PlistBuddy -c "Set :LSUIElement true" "$PLIST"
echo "④ 同綑 collector 進 app bundle(托盤 collectorBinPath 找同層)"
cp arcrun-collector "$APP/Contents/MacOS/arcrun-collector"
echo "⑤ ad-hoc 重簽(Apple Silicon:改過 plist/塞過檔必重簽,否則 launchd 拒開 error 162——07-24 真機實撞)"
codesign --force --deep -s - "$APP"
echo "✅ 完成:$APP"
echo "驗法:open '$APP' → 選單列出現 icon、Dock **不出現** icon → 選單列出資料夾清單"