-
Notifications
You must be signed in to change notification settings - Fork 18
/
Make.sh
46 lines (31 loc) · 934 Bytes
/
Make.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
#!/usr/bin/env bash
Version=2.0.0
Platform=$1
if [[ "$Platform" == "" ]]; then
Platform=$(go env GOHOSTOS)
fi
function ReportError()
{
if [ $? -ne 0 ] ; then read -rsp $'Errors occurred...\n' ; fi
}
trap ReportError EXIT
set -e
if [[ "$Platform" == "" ]]; then
Platform=$(go env GOHOSTOS)
fi
#export GOARCH=amd64
BuildSourcePackage="github.com/davyxu/protoplus/build"
BinaryPackage="github.com/davyxu/protoplus/cmd/protoplus"
BinaryName="protoplus"
BuildBinary()
{
TargetDir=bin/"${1}"
mkdir -p "${TargetDir}"
export GOOS=${1}
BuildTime=$(date -R)
GitCommit=$(git rev-parse HEAD)
VersionString="-X \"${BuildSourcePackage}.BuildTime=${BuildTime}\" -X \"${BuildSourcePackage}.Version=${Version}\" -X \"${BuildSourcePackage}.GitCommit=${GitCommit}\""
go build -p 4 -o "${TargetDir}"/${BinaryName} -ldflags "${VersionString}" ${BinaryPackage}
echo "${TargetDir}"/${BinaryName}
}
BuildBinary "${Platform}"