#!/usr/bin/env bash # Build dsh-launcher.app for macOS (universal arm64/x86_64). # # 用法: ./scripts/build-mac.sh # # 产物: build/bin/dsh-launcher.app # 安装: ./scripts/install-app.sh (拷贝到 /Applications/ + 刷新图标缓存) # # 注意: Wails v2 跨平台 build 需要在目标平台编译。 # 想出 Windows 版,必须在 Windows 上跑 scripts/build-windows.bat。 set -euo pipefail cd "$(dirname "$0")/.." echo "▶ dsh-launcher · macOS build" echo "" # 1. 基础工具检查 command -v go >/dev/null 2>&1 || { echo "✗ go not installed"; exit 1; } command -v node >/dev/null 2>&1 || { echo "✗ node not installed"; exit 1; } command -v npm >/dev/null 2>&1 || { echo "✗ npm not installed"; exit 1; } command -v wails >/dev/null 2>&1 || { echo "✗ wails not installed (go install github.com/wailsapp/wails/v2/cmd/wails@latest)"; exit 1; } GOOS=$(go env GOOS) if [[ "${GOOS}" != "darwin" ]]; then echo "✗ must run on macOS (current: ${GOOS})" exit 1 fi # 2. 同步前端依赖(版本变更后才需要,但每次跑更稳) echo "▶ npm install" (cd frontend && npm install) # 3. 编译 # -clean: 清掉 build/bin,确保 icns / Info.plist 跟当前源码一致 # 不带 -platform: 当前平台 + 当前架构 echo "" echo "▶ wails build" wails build -clean # 4. 校验产物 APP="build/bin/dsh-launcher.app" if [[ ! -d "${APP}" ]]; then echo "✗ ${APP} not found" exit 1 fi if [[ ! -f "${APP}/Contents/Resources/iconfile.icns" ]]; then echo "✗ iconfile.icns missing" exit 1 fi ICON_SIZE=$(stat -f%z "${APP}/Contents/Resources/iconfile.icns") EXE_SIZE=$(stat -f%z "${APP}/Contents/MacOS/dsh-launcher") echo "" echo "✓ app: ${APP}" echo " binary: ${EXE_SIZE} bytes" echo " icon: ${ICON_SIZE} bytes" echo "" echo " open: open ${APP}" echo " install: ./scripts/install-app.sh"