-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·53 lines (50 loc) · 1.21 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
#!/bin/sh -xe
ldflags="-s -w -X main.gitCommit=$(git rev-list --abbrev-commit -1 HEAD)"
src=./cmd/netpunch/...
if test $# = 0
then
go build -ldflags "$ldflags" $src
exit
fi
while test $# != 0
do
case "$1" in
-b)
go build -ldflags "$ldflags" $src
;;
-c)
if test $# = 1
then
echo 'You have to specify os/platform'
exit 1
fi
shift
export GOOS="${1%/*}"
export GOARCH="${1#*/}"
go build -ldflags "$ldflags" -o netpunch-$GOOS-$GOARCH $src
;;
-l)
go tool dist list
break
;;
-h)
echo 'Usage:'
echo '-b'
echo ' just build'
echo '-c os/arch'
echo ' cross compile; see -l'
echo '-l'
echo ' list of available options for cross compilation'
echo '-h'
echo ' usage'
echo
echo 'Example:'
echo './build.sh -b -c linux/386 -c darwin/amd64'
break
;;
*)
echo 'Invalid option, try -h'
exit 1
esac
shift
done