-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathbuild.sh
More file actions
190 lines (165 loc) ยท 6.69 KB
/
build.sh
File metadata and controls
190 lines (165 loc) ยท 6.69 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/usr/bin/env bash
# ClawPanel ๆฌๅฐๆๅปบ่ๆฌ๏ผmacOS / Linux๏ผ
# ็จๆณ:
# ./build.sh โ ๆๅปบๅฝๅๅนณๅฐๅฎ่ฃ
ๅ
๏ผ้ป่ฎค๏ผ
# ./build.sh --debug โ Debug ๆๅปบ๏ผๅฟซ๏ผไธๆๅ
๏ผ
# ./build.sh --clean โ ๆธ
็ Rust ็ผ่ฏ็ผๅญๅๆๅปบ
# ./build.sh --target <triple> โ ๆๅฎ Rust target๏ผๅฆ x86_64-unknown-linux-gnu๏ผ
set -euo pipefail
DEBUG=false
CLEAN=false
TARGET=""
while [[ $# -gt 0 ]]; do
case "$1" in
--debug) DEBUG=true; shift ;;
--clean) CLEAN=true; shift ;;
--target) TARGET="$2"; shift 2 ;;
*) shift ;;
esac
done
RED='\033[0;31m'; GREEN='\033[0;32m'; CYAN='\033[0;36m'
MAGENTA='\033[0;35m'; GRAY='\033[0;90m'; RESET='\033[0m'
step() { echo -e "\n${CYAN}โถ $1${RESET}"; }
ok() { echo -e " ${GREEN}โ $1${RESET}"; }
fail() { echo -e " ${RED}โ $1${RESET}"; exit 1; }
echo ""
ARCH=$(uname -m)
OS=$(uname)
echo -e " ${MAGENTA}ClawPanel ๆๅปบๅทฅๅ
ท${RESET}"
echo -e " ${GRAY}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${RESET}"
if [[ "$OS" == "Darwin" ]]; then
if [[ "$ARCH" == "arm64" ]]; then
echo -e " ${GRAY}ๅนณๅฐ: macOS Apple Silicon (aarch64)${RESET}"
else
echo -e " ${GRAY}ๅนณๅฐ: macOS Intel (x86_64)${RESET}"
fi
else
echo -e " ${GRAY}ๅนณๅฐ: Linux ${ARCH}${RESET}"
fi
if [[ -n "$TARGET" ]]; then
echo -e " ${CYAN}็ฎๆ : $TARGET${RESET}"
fi
echo -e " ${GRAY}่ทจๅนณๅฐๆๅปบ (ๅ
ถไปๅนณๅฐ) ่ฏทๆจ้ tag ่งฆๅ GitHub Actions${RESET}"
echo ""
# โโ ็ฏๅขๆฃๆต โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
step "ๆฃๆฅๆๅปบไพ่ต"
if ! command -v node &>/dev/null; then
fail "ๆชๆพๅฐ Node.js๏ผ่ฏทไป https://nodejs.org ๅฎ่ฃ
v18+"
fi
ok "Node.js $(node --version)"
if ! command -v cargo &>/dev/null; then
fail "ๆชๆพๅฐ Rust/Cargo๏ผ่ฏทไป https://rustup.rs ๅฎ่ฃ
"
fi
ok "Rust $(rustc --version)"
# macOS ้ขๅคๆฃๆต
if [[ "$(uname)" == "Darwin" ]]; then
if ! command -v xcode-select &>/dev/null || ! xcode-select -p &>/dev/null 2>&1; then
echo -e " ${YELLOW}โ ๆชๆพๅฐ Xcode Command Line Tools${RESET}"
echo -e " ่ฟ่ก: xcode-select --install"
fi
fi
# Linux ้ขๅคๆฃๆต
if [[ "$OS" == "Linux" ]]; then
if command -v dpkg &>/dev/null; then
# Debian/Ubuntu
MISSING=()
for pkg in libwebkit2gtk-4.1-dev libssl-dev libgtk-3-dev; do
if ! dpkg -s "$pkg" &>/dev/null 2>&1; then
MISSING+=("$pkg")
fi
done
if [ ${#MISSING[@]} -gt 0 ]; then
echo -e " ${RED}โ ็ผบๅฐ็ณป็ปไพ่ต: ${MISSING[*]}${RESET}"
echo -e " ่ฟ่ก: sudo apt-get install -y ${MISSING[*]} libayatana-appindicator3-dev librsvg2-dev patchelf"
exit 1
fi
elif command -v rpm &>/dev/null; then
# Fedora/RHEL/CentOS
MISSING=()
for pkg in webkit2gtk4.1-devel openssl-devel gtk3-devel; do
if ! rpm -q "$pkg" &>/dev/null 2>&1; then
MISSING+=("$pkg")
fi
done
if [ ${#MISSING[@]} -gt 0 ]; then
echo -e " ${RED}โ ็ผบๅฐ็ณป็ปไพ่ต: ${MISSING[*]}${RESET}"
echo -e " ่ฟ่ก: sudo dnf install -y ${MISSING[*]} libayatana-appindicator-gtk3-devel librsvg2-devel patchelf"
exit 1
fi
else
echo -e " ${GRAY}โ ๆ ๆณ่ชๅจๆฃๆต็ณป็ปไพ่ต๏ผ่ฏท็กฎไฟๅทฒๅฎ่ฃ
WebKit2GTK 4.1ใOpenSSLใGTK3 ๅผๅๅ
${RESET}"
fi
fi
# โโ ไพ่ตๅฎ่ฃ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
step "ๅฎ่ฃ
ๅ็ซฏไพ่ต"
if [ ! -d "node_modules" ]; then
npm ci --silent
ok "ไพ่ตๅฎ่ฃ
ๅฎๆ"
else
ok "ไพ่ตๅทฒๅญๅจ๏ผ่ทณ่ฟ"
fi
# โโ ๆธ
็็ผๅญ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
if [ "$CLEAN" = true ]; then
step "ๆธ
็ Rust ็ผ่ฏ็ผๅญ"
(cd src-tauri && cargo clean)
ok "็ผๅญๅทฒๆธ
็"
fi
# โโ ๆๅปบ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
START_TIME=$(date +%s)
# ๆๅปบๅๆฐ
BUILD_ARGS=""
if [[ -n "$TARGET" ]]; then
rustup target add "$TARGET" 2>/dev/null || true
BUILD_ARGS="--target $TARGET"
fi
if [ "$DEBUG" = true ]; then
step "Debug ๆๅปบ๏ผไธๆๅ
ๅฎ่ฃ
ๅจ๏ผ"
npm run tauri build -- --debug $BUILD_ARGS
else
step "Release ๆๅปบ"
if [[ -n "$TARGET" ]]; then
echo -e " ${GRAY}็ฎๆ : $TARGET${RESET}"
npm run tauri build -- $BUILD_ARGS
elif [[ "$OS" == "Darwin" ]] && [[ "$ARCH" == "arm64" ]]; then
# macOS Apple Silicon: ๆๅปบ ARM64 ็ๆฌ
rustup target add x86_64-apple-darwin 2>/dev/null || true
echo -e " ${GRAY}ๆๅปบ ARM64 ็ๆฌ...${RESET}"
npm run tauri build -- --target aarch64-apple-darwin
else
npm run tauri build
fi
fi
END_TIME=$(date +%s)
ELAPSED=$((END_TIME - START_TIME))
# โโ ่พๅบ็ปๆ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
echo ""
echo -e " ${GREEN}โ
ๆๅปบๆๅ๏ผ่ๆถ ${ELAPSED}s${RESET}"
echo -e " ${GRAY}โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ${RESET}"
if [ "$DEBUG" = true ]; then
if [[ -n "$TARGET" ]]; then
echo -e " ๅฏๆง่กๆไปถ: src-tauri/target/$TARGET/debug/clawpanel"
else
echo -e " ๅฏๆง่กๆไปถ: src-tauri/target/debug/clawpanel"
fi
else
if [[ -n "$TARGET" ]]; then
BUNDLE_DIR="src-tauri/target/$TARGET/release/bundle"
else
BUNDLE_DIR="src-tauri/target/release/bundle"
fi
if [[ "$OS" == "Darwin" ]]; then
DMG=$(find "$BUNDLE_DIR/dmg" -name "*.dmg" 2>/dev/null | head -1)
APP=$(find "$BUNDLE_DIR/macos" -name "*.app" -maxdepth 1 2>/dev/null | head -1)
[ -n "$DMG" ] && echo -e " DMG: ${GRAY}$DMG${RESET}"
[ -n "$APP" ] && echo -e " APP: ${GRAY}$APP${RESET}"
else
APPIMAGE=$(find "$BUNDLE_DIR/appimage" -name "*.AppImage" 2>/dev/null | head -1)
DEB=$(find "$BUNDLE_DIR/deb" -name "*.deb" 2>/dev/null | head -1)
[ -n "$APPIMAGE" ] && echo -e " AppImage: ${GRAY}$APPIMAGE${RESET}"
[ -n "$DEB" ] && echo -e " DEB: ${GRAY}$DEB${RESET}"
fi
fi
echo ""
echo -e " ${GRAY}ๆ็คบ: ๅๅธ่ทจๅนณๅฐ็ๆฌ่ฏทๆจ้ tag๏ผไพๅฆ:${RESET}"
echo -e " ${GRAY} git tag v1.0.0 && git push origin v1.0.0${RESET}"
echo ""