forked from etcd-io/etcd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·33 lines (26 loc) · 909 Bytes
/
build
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
#!/bin/sh -e
ORG_PATH="github.com/coreos"
REPO_PATH="${ORG_PATH}/etcd"
export GOPATH=${PWD}/gopath
rm -f $GOPATH/src/${REPO_PATH}
mkdir -p $GOPATH/src/${ORG_PATH}
ln -s ${PWD} $GOPATH/src/${REPO_PATH}
eval $(go env)
GIT_SHA=`git rev-parse --short HEAD || echo "GitNotFound"`
val=$(go version)
# if 'go version' contains string 'devel', it assumes the go tip branch,
# which is greater than go 1.5+.
if [[ $val == *"devel"* ]]
then
LINK_OPERATOR="="
else
ver=$(echo $val | awk -F ' ' '{print $3}' | awk -F '.' '{print $2}')
if [ $ver -gt 4 ]; then
LINK_OPERATOR="="
else
LINK_OPERATOR=" "
fi
fi
# Static compilation is useful when etcd is run in a container
CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "-s -X ${REPO_PATH}/version.GitSHA${LINK_OPERATOR}${GIT_SHA}" -o bin/etcd ${REPO_PATH}
CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags "-s" -o bin/etcdctl ${REPO_PATH}/etcdctl