mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
23 lines
776 B
Bash
Executable File
23 lines
776 B
Bash
Executable File
#!/bin/sh -e
|
|
|
|
# set some environment variables
|
|
ORG_PATH="github.com/coreos"
|
|
REPO_PATH="${ORG_PATH}/etcd"
|
|
export GO15VENDOREXPERIMENT="1"
|
|
eval $(go env)
|
|
GIT_SHA=`git rev-parse --short HEAD || echo "GitNotFound"`
|
|
|
|
etcd_build() {
|
|
if [ -z "${GOARCH}" ] || [ "${GOARCH}" = "$(go env GOHOSTARCH)" ]; then
|
|
out="bin"
|
|
else
|
|
out="bin/${GOARCH}"
|
|
fi
|
|
# Static compilation is useful when etcd is run in a container
|
|
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "-s -X ${REPO_PATH}/cmd/vendor/${REPO_PATH}/version.GitSHA=${GIT_SHA}" -o ${out}/etcd ${REPO_PATH}/cmd
|
|
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "-s" -o ${out}/etcdctl ${REPO_PATH}/cmd/etcdctl
|
|
}
|
|
|
|
# don't build when sourced
|
|
(echo "$0" | grep "/build$") && etcd_build || true
|