-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·65 lines (54 loc) · 1.81 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·65 lines (54 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
APP_NAME="Flock"
APP="$SCRIPT_DIR/$APP_NAME.app"
SRC="$SCRIPT_DIR/app"
WEB_DIR="$SCRIPT_DIR/web"
DAEMON_DIR="$SCRIPT_DIR/daemon"
echo "=== 编译 Flock ==="
# 1. Quit existing
osascript -e "tell application \"$APP_NAME\" to quit" 2>/dev/null || true
sleep 1
# 2. Install dependencies
echo " → 安装依赖..."
(cd "$DAEMON_DIR" && bun install --frozen-lockfile)
(cd "$WEB_DIR" && bun install --frozen-lockfile)
# 3. Build web
echo " → 编译 Web UI..."
(cd "$WEB_DIR" && bun run build 2>&1 | tail -3)
# 4. Create .app bundle
rm -rf "$APP"
mkdir -p "$APP/Contents/MacOS" "$APP/Contents/Resources"
cp "$SRC/Info.plist" "$APP/Contents/"
echo -n "APPL????" > "$APP/Contents/PkgInfo"
[ -f "$SRC/AppIcon.icns" ] && cp "$SRC/AppIcon.icns" "$APP/Contents/Resources/"
# 5. Bundle web dist
if [ -d "$WEB_DIR/dist" ]; then
echo " → 打包 Web UI 到 app bundle..."
cp -r "$WEB_DIR/dist" "$APP/Contents/Resources/web-dist"
fi
# 6. Bundle daemon source (app spawns daemon at runtime)
echo " → 打包 daemon..."
mkdir -p "$APP/Contents/Resources/daemon"
cp -r "$DAEMON_DIR/src" "$APP/Contents/Resources/daemon/src"
cp "$DAEMON_DIR/package.json" "$APP/Contents/Resources/daemon/"
cp -r "$DAEMON_DIR/node_modules" "$APP/Contents/Resources/daemon/node_modules" 2>/dev/null || true
# 7. Compile Swift
echo " → 编译 Swift..."
swiftc \
"$SRC/AppDelegate.swift" \
"$SRC/main.swift" \
-o "$APP/Contents/MacOS/Flock" \
-framework Cocoa \
-framework WebKit \
-target arm64-apple-macos13.0 \
-suppress-warnings
# 8. Sign
xattr -cr "$APP" 2>/dev/null || true
codesign --force --deep --sign - "$APP"
echo " ✓ $APP_NAME.app"
echo ""
echo "=== 完成 ==="
echo "启动:open \"$APP\""
echo "开发模式:\"$APP/Contents/MacOS/Flock\" --dev"