-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.sh
executable file
·52 lines (42 loc) · 1.11 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
#!/bin/bash -
set -eu
VERSION=$(git describe --abbrev=0 --tags)
REVCNT=$(git rev-list --count HEAD)
DEVCNT=$(git rev-list --count $VERSION)
if test $REVCNT != $DEVCNT
then
VERSION="$VERSION.dev$(expr $REVCNT - $DEVCNT)"
fi
echo "VER: $VERSION"
GITCOMMIT=$(git rev-parse HEAD)
BUILDTIME=$(date -u +%Y/%m/%d-%H:%M:%S)
LDFLAGS="-X main.VERSION=$VERSION -X main.BUILDTIME=$BUILDTIME -X main.GITCOMMIT=$GITCOMMIT"
if [[ -n "${EX_LDFLAGS:-""}" ]]
then
LDFLAGS="$LDFLAGS $EX_LDFLAGS"
fi
build(){
echo "$1 $2 ..."
GOOS=$1 GOARCH=$2 go build \
-o dist/xmysql-server-${3:-""} \
-tags vfs \
-ldflags "$LDFLAGS" \
-gcflags "all=-N -l" \
/Users/zhukovasky/GolandProjects/xmysql-server/main.go
}
go generate .
#build linux arm linux-arm
build darwin amd64 mac-amd64
#build linux amd64 linux-amd64
#build linux 386 linux-386
#build windows amd64 win-amd64.exe
buildClient() {
echo "$1 $2 ..."
GOOS=$1 GOARCH=$2 go build \
-o dist/xmysql-server-client-${3:-""} \
-tags vfs \
-ldflags "$LDFLAGS" \
-gcflags "all=-N -l" \
/Users/zhukovasky/GolandProjects/xmysql-server/client/main.go
}
buildClient darwin amd64 mac-amd64