-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathbuild_macos.sh
executable file
·98 lines (76 loc) · 3.32 KB
/
build_macos.sh
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
#!/bin/bash
#shellcheck source=/dev/null
source ./env.sh
WINDSEND_RUST_SERVER_BIN_NAME="WindSend-S-Rust"
mkdir -p ./bin
chmod +x ./*.sh
# 检查环境变量是否已经设置
if [ -z "$WINDSEND_PROJECT_VERSION" ]; then
read -rp "WINDSEND_PROJECT_VERSION:v" WINDSEND_PROJECT_VERSION
fi
# 若指定了版本号,则修改项目中的版本号
if [ -n "$WINDSEND_PROJECT_VERSION" ]; then
echo "WINDSEND_PROJECT_VERSION: $WINDSEND_PROJECT_VERSION"
export WINDSEND_PROJECT_VERSION
./version.sh
fi
######################################################################################
# Build WindSend Rust for x86_64
WindSendRustBin_X86_64DirName="WindSend-macos-x64-S-Rust-$BUILD_TAG"
rustBinName="wind_send"
rustTarget="x86_64-apple-darwin"
cd "$WINDSEND_PROJECT_PATH" || exit
cd "$WINDSEND_RUST_PROJECT_PATH" || exit
if ! cargo build --target $rustTarget --verbose --release; then
echo "Build x86_64 Failed!"
exit 1
fi
mkdir -p ../bin/"$WindSendRustBin_X86_64DirName"
cp -r target/$rustTarget/release/$rustBinName ../bin/"$WindSendRustBin_X86_64DirName"
mv ../bin/"$WindSendRustBin_X86_64DirName"/$rustBinName ../bin/"$WindSendRustBin_X86_64DirName"/$WINDSEND_RUST_SERVER_BIN_NAME
cd "$WINDSEND_PROJECT_PATH" || exit
cp README.md ./bin/"$WindSendRustBin_X86_64DirName"
cp README-EN.md ./bin/"$WindSendRustBin_X86_64DirName"
cp "$WINDSEND_RUST_PROJECT_PATH/$SERVER_PROGRAM_ICON_NAME" ./bin/"$WindSendRustBin_X86_64DirName"
cd ./bin || exit
zip -r "$WindSendRustBin_X86_64DirName".zip "$WindSendRustBin_X86_64DirName"
######################################################################################
# Build WindSend for aarch64
WindSendRustBin_X86_64DirName="WindSend-macos-arm64-S-Rust-$BUILD_TAG"
rustBinName="wind_send"
rustTarget="aarch64-apple-darwin"
cd "$WINDSEND_PROJECT_PATH" || exit
cd "$WINDSEND_RUST_PROJECT_PATH" || exit
if ! cargo build --target $rustTarget --verbose --release; then
echo "Build aarch64 Failed!"
exit 1
fi
mkdir -p ../bin/"$WindSendRustBin_X86_64DirName"
cp -r target/$rustTarget/release/$rustBinName ../bin/"$WindSendRustBin_X86_64DirName"
mv ../bin/"$WindSendRustBin_X86_64DirName"/$rustBinName ../bin/"$WindSendRustBin_X86_64DirName"/$WINDSEND_RUST_SERVER_BIN_NAME
cd "$WINDSEND_PROJECT_PATH" || exit
cp README.md ./bin/"$WindSendRustBin_X86_64DirName"
cp README-EN.md ./bin/"$WindSendRustBin_X86_64DirName"
cp "$WINDSEND_RUST_PROJECT_PATH/$SERVER_PROGRAM_ICON_NAME" ./bin/"$WindSendRustBin_X86_64DirName"
cd ./bin || exit
zip -r "$WindSendRustBin_X86_64DirName".zip "$WindSendRustBin_X86_64DirName"
######################################################################################
# Press Enter to continue building WindSend Flutter for x86_64
if ! TheVariableIsTrue "$CI_RUNNING"; then
read -rp "Press Enter to continue..."
fi
flutterX86_64DirName="WindSend-macos-x64-flutter-$BUILD_TAG"
# Build WindSend Flutter for x86_64
cd "$WINDSEND_PROJECT_PATH" || exit
cd "$WINDSEND_FLUTTER_PATH" || exit
if ! flutter build macos --release; then
echo "Build Failed!"
exit 0
fi
mkdir -p ../../bin/"$flutterX86_64DirName"
cp -r build/macos/Build/Products/Release/* ../../bin/"$flutterX86_64DirName"
cd "$WINDSEND_PROJECT_PATH" || exit
cp README.md ./bin/"$flutterX86_64DirName"
cp README-EN.md ./bin/"$flutterX86_64DirName"
cd ./bin || exit
zip -r "$flutterX86_64DirName".zip "$flutterX86_64DirName"