-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
151 lines (121 loc) · 5.23 KB
/
build.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
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
#!/bin/bash
###
# @Descripttion:
# @version:
# @Author: Wynters
# @Date: 2024-05-05 23:03:31
# @LastEditTime: 2024-05-27 17:46:55
# @FilePath: \RustPanel\build.sh
#
#
#docker run -d -v F:/Users/Wynters/rust/RustPanel:/build rust:alpine3.19 tail -f NUL
#apk update
#apk add libc-dev
###
echo ">>> Building RustPanel in release mode..."
OS=$(uname)
case "$OS" in
Linux)
#LINK="x86_64-unknown-linux-gnu"
LINK="x86_64-unknown-linux-musl"
VERSION=$(grep 'version =' ./Cargo.toml | grep -o '[0-9]*\.[0-9]*\.[0-9]*')
TARGET_DIR="./target/$LINK/release/RustPanel"
rm -rf "$TARGET_DIR"
rm -rf "./target/$LINK/release/panel"
rm -rf "./target/$LINK/release/rp"
cargo build --target "$LINK" --release
if [ $? -ne 0 ]; then
echo ">>> Error: Cargo build failed from Linux"
else
#mv "$TARGET_DIR" "./target/$LINK/release/panel"
echo "Cargo build successful from $LINK"
mkdir -p "$TARGET_DIR"
mkdir -p "$TARGET_DIR/bin"
mkdir -p "$TARGET_DIR/runtime"
mkdir -p "$TARGET_DIR/wwwroot"
mkdir -p "$TARGET_DIR/server"
dirs="addons config public locales wwwroot server"
for dir in $dirs; do
cp -r "./$dir" "$TARGET_DIR" > /dev/null
if [ $? -ne 0 ]; then
echo "error: copy $dir to $TARGET_DIR fial"
exit 1
fi
done
cp "./target/$LINK/release/rp" "$TARGET_DIR/bin/rp"
cp "./target/$LINK/release/panel" "$TARGET_DIR/panel"
./build/upx -9 -qvf "$TARGET_DIR/panel" "$TARGET_DIR/bin/rp"
echo $(grep 'version =' ./Cargo.toml | grep -o '[0-9]*\.[0-9]*\.[0-9]*' | tail -n1) > "$TARGET_DIR/VERSION"
rm -rf "./target/RustPanel_$VERSION-$LINK.tar.gz"
tar -czvf "./target/RustPanel_$VERSION-$LINK.tar.gz" -C "./target/$LINK/release" RustPanel > NUL
echo ">>> :) build successful, directory in: $TARGET_DIR"
fi
;;
Win*)
LINK="x86_64-pc-windows-msvc"
VERSION=$(grep 'version =' ./Cargo.toml | grep -o '[0-9]*\.[0-9]*\.[0-9]*')
TARGET_DIR="./target/$LINK/release/RustPanel"
rm -rf "./target/$LINK/release/*.*"
rm -rf "$TARGET_DIR"
cargo build --target "$LINK" --release
if [ $? -ne 0 ]; then
echo ">>> Error: Cargo build failed from Windows"
else
#mv "$TARGET_DIR.exe" "./target/$LINK/release/panel.exe"
echo "Cargo build successful from $LINK"
mkdir -p "$TARGET_DIR"
mkdir -p "$TARGET_DIR/bin"
mkdir -p "$TARGET_DIR/runtime"
mkdir -p "$TARGET_DIR/wwwroot"
mkdir -p "$TARGET_DIR/server"
dirs="addons config public locales wwwroot server"
for dir in $dirs; do
cp -r "./$dir" "$TARGET_DIR" > /dev/null
if [ $? -ne 0 ]; then
echo "error: copy $dir to $TARGET_DIR fial"
exit 1
fi
done
cp "./target/$LINK/release/rp.exe" "$TARGET_DIR/bin/rp.exe"
cp "./target/$LINK/release/panel.exe" "$TARGET_DIR/panel.exe"
echo $(grep 'version =' ./Cargo.toml | grep -o '[0-9]*\.[0-9]*\.[0-9]*' | tail -n1) > "$TARGET_DIR/VERSION"
rm -rf "./target/RustPanel_$VERSION-$LINK.tar.gz"
tar -czvf "./target/RustPanel_$VERSION-$LINK.tar.gz" -C "./target/$LINK/release" RustPanel > NUL
echo ">>> :) build successful, directory in: $TARGET_DIR"
fi
;;
*)
VERSION=$(grep 'version =' ./Cargo.toml | grep -o '[0-9]*\.[0-9]*\.[0-9]*')
TARGET_DIR="./target/release/RustPanel"
rm -rf "$TARGET_DIR"
rm -rf "./target/$LINK/release/panel"
rm -rf "./target/$LINK/release/rp"
cargo build --release
if [ $? -ne 0 ]; then
echo ">>> Error: Cargo build failed from $OS"
else
#mv "$TARGET_DIR" "./target/release/panel"
echo "Cargo build successful from $LINK"
mkdir -p "$TARGET_DIR"
mkdir -p "$TARGET_DIR/bin"
mkdir -p "$TARGET_DIR/runtime"
mkdir -p "$TARGET_DIR/wwwroot"
mkdir -p "$TARGET_DIR/server"
dirs="addons config public locales wwwroot server"
for dir in $dirs; do
cp -r "./$dir" "$TARGET_DIR" > /dev/null
if [ $? -ne 0 ]; then
echo "error: copy $dir to $TARGET_DIR fial"
exit 1
fi
done
cp "./target/release/rp" "$TARGET_DIR/bin/rp"
cp "./target/release/panel" "$TARGET_DIR/panel"
./build/upx -9 -qvf "$TARGET_DIR/panel" "$TARGET_DIR/bin/rp"
echo $(grep 'version =' ./Cargo.toml | grep -o '[0-9]*\.[0-9]*\.[0-9]*' | tail -n1) > "$TARGET_DIR/VERSION"
rm -rf "./target/RustPanel_$VERSION-$LINK.tar.gz"
tar -czvf "./target/RustPanel_$VERSION-$LINK.tar.gz" -C "./target/release" RustPanel > NUL
echo ">>> :) build successful, directory in: $TARGET_DIR"
fi
;;
esac