blob: e233cd56a27f2fede7f0ed8ded8cb4afb1ee73dd (
plain)
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
|
#!/bin/bash
SRCDIR=$(pwd)
# Go options
export GOPATH="$GOPATH:$SRCDIR"
export GO111MODULE="off"
# Build windows
win () {
export GOOS=windows
go build -o build/${1}.exe src/${1}.go
}
# Build linux
linux () {
export GOOS=linux
go build -o build/${1} src/${1}.go
}
# Build mac
mac () {
export GOOS=darwin
go build -o build/${1} src/${1}.go
}
# Build all
all () {
win $1
mac $1
linux $1
}
# Help text
print_help () {
echo ""
echo "Usage: gobuild.sh [os] [program] <arch>"
echo ""
echo " os: (mac, linux, win, all)"
echo " prog: (tint, parse)"
echo " arch: any supported go arch for the target os"
echo ""
}
# Check if given os is valid
is_os () {
if [[($1 == "mac") || ($1 == "linux") || ($1 == "win") || ($1 == "all")]]; then
return 0
fi
return 1
}
if [[ -n $3 ]]; then
export GOARCH=$3
fi
if $(is_os $1); then
if [[ -z $2 ]]; then
$1 tint
$1 parse
else
$1 $2
fi
else
print_help
fi
|