This repository has been archived by the owner on Mar 22, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathbuild.sh
executable file
·63 lines (52 loc) · 1.61 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
#!/bin/bash
OS="local"
while getopts "lh:" arg
do
case $arg in
h) #help带all参数仅用于测试脚本,并备忘
echo "-h [all] help"
case $OPTARG in
all)
echo "-l build linux bin, default local"
;;
esac
exit
;;
l)
OS="linux"
;;
?)
echo "unkonw argument"
echo "-h all help"
echo "-l build linux bin, default local"
exit 1
;;
esac
done
# Go Path
# CURDIR=`pwd`
# OLDGOPATH="$GOPATH"
# export GOPATH="$OLDGOPATH:$CURDIR"
LogPrefix=">>>>"
# 打包前检测Bindata是否开启
echo -e "$LogPrefix `date +"%H:%M:%S"` \033[42;37m start \033[0m"
echo "$LogPrefix `date +"%H:%M:%S"` assets bindata"
go-bindata -ignore=\\.DS_Store -ignore=assets.go -pkg="assets" -o assets/assets.go assets/...
echo "$LogPrefix `date +"%H:%M:%S"` template bindata"
go-bindata -ignore=\\.DS_Store -ignore=template.go -pkg="template" -o template/template.go template/...
# echo "$LogPrefix `date +"%H:%M:%S"` src package"
# gofmt -w src/
# 交叉编译
case $OS in
linux)
# Linux
echo "$LogPrefix `date +"%H:%M:%S"` build linux bin"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags '-w' -o echo-web ./echo.go
;;
*)
# 本机
echo "$LogPrefix `date +"%H:%M:%S"` build local bin"
go build -a -installsuffix cgo -ldflags '-w' -o echo-web ./echo.go
;;
esac
echo -e "$LogPrefix `date +"%H:%M:%S"` \033[42;37m finished \033[0m"