-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sh
70 lines (58 loc) · 3.42 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
if [ -z "$1" ]
then
read -p "版本号: " VERSION
else
VERSION=$1
fi
echo "版本号是:$VERSION"
echo "Building MirouterUI $VERSION..."
OUTPUT_DIR="./build"
echo "编译生成目录:$OUTPUT_DIR"
mkdir -p $OUTPUT_DIR
if [ -z "$2" ] || [ "$2" = "win" ]
then
echo "Building win_amd64"
GOOS=windows GOARCH=amd64 go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_win_amd64_noupx_$VERSION.exe main.go
upx --best -o $OUTPUT_DIR/mirouterui_win_amd64_$VERSION.exe $OUTPUT_DIR/mirouterui_win_amd64_noupx_$VERSION.exe
echo "Building win_386"
GOOS=windows GOARCH=386 go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_win_386_noupx_$VERSION.exe main.go
upx --best -o $OUTPUT_DIR/mirouterui_win_386_$VERSION.exe $OUTPUT_DIR/mirouterui_win_386_noupx_$VERSION.exe
echo "Building win_arm64"
GOOS=windows GOARCH=arm64 go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_win_arm64_noupx_$VERSION.exe main.go
# rm main.exe
fi
if [ -z "$2" ] || [ "$2" = "linux" ]
then
echo "Building linux_amd64"
GOOS=linux GOARCH=amd64 go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_linux_amd64_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_linux_amd64_$VERSION $OUTPUT_DIR/mirouterui_linux_amd64_noupx_$VERSION
echo "Building linux_arm64"
GOOS=linux GOARCH=arm64 go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_linux_arm64_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_linux_arm64_$VERSION $OUTPUT_DIR/mirouterui_linux_arm64_noupx_$VERSION
echo "Building linux_mipsle"
GOOS=linux GOARCH=mipsle GOMIPS=softfloat go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_linux_mipsle_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_linux_mipsle_$VERSION $OUTPUT_DIR/mirouterui_linux_mipsle_noupx_$VERSION
echo "Building linux_mips"
GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_linux_mips_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_linux_mips_$VERSION $OUTPUT_DIR/mirouterui_linux_mips_noupx_$VERSION
echo "Building linux_s390x"
GOOS=linux GOARCH=s390x go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_linux_s390x_noupx_$VERSION main.go
# upx --best -o $OUTPUT_DIR/mirouterui_linux_s390x_$VERSION $OUTPUT_DIR/mirouterui_linux_s390x_noupx_$VERSION
for version in 5 6 7
do
echo "Building linux_armv$version"
GOOS=linux GOARCH=arm GOARM=$version GOMIPS=softfloat go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_linux_armv${version}_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_linux_armv${version}_$VERSION $OUTPUT_DIR/mirouterui_linux_armv${version}_noupx_$VERSION
done
fi
if [ -z "$2" ] || [ "$2" = "darwin" ]
then
# Building darwin_amd64
echo "Building darwin_amd64"
GOOS=darwin GOARCH=amd64 go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_darwin_amd64_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_darwin_amd64_$VERSION $OUTPUT_DIR/mirouterui_darwin_amd64_noupx_$VERSION
# Building darwin_arm64
echo "Building darwin_arm64"
GOOS=darwin GOARCH=arm64 go build -ldflags "-X 'main.Version=$VERSION'" -o $OUTPUT_DIR/mirouterui_darwin_arm64_noupx_$VERSION main.go
upx --best -o $OUTPUT_DIR/mirouterui_darwin_arm64_$VERSION $OUTPUT_DIR/mirouterui_darwin_arm64_noupx_$VERSION
fi