https://github.com/etcd-io/etcd
Raw File
Tip revision: cc198e22d3b8fd7ec98304c95e68ee375be54589 authored by Gyu-Ho Lee on 20 January 2017, 19:02:34 UTC
version: bump to v3.0.17
Tip revision: cc198e2
build
#!/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"`
if [ ! -z "$FAILPOINTS" ]; then
	GIT_SHA="$GIT_SHA"-FAILPOINTS
fi

# enable/disable failpoints
toggle_failpoints() {
	FAILPKGS="etcdserver/"

	mode="disable"
	if [ ! -z "$FAILPOINTS" ]; then mode="enable"; fi
	if [ ! -z "$1" ]; then mode="$1"; fi

	if which gofail >/dev/null 2>&1; then
		gofail "$mode" $FAILPKGS
	elif [ "$mode" != "disable" ]; then
		echo "FAILPOINTS set but gofail not found"
		exit 1
	fi
}

etcd_build() {
	if [ -z "${GOARCH}" ] || [ "${GOARCH}" = "$(go env GOHOSTARCH)" ]; then
		out="bin"
	else
		out="bin/${GOARCH}"
	fi
	toggle_failpoints
	# 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
}

toggle_failpoints

# don't build when sourced
(echo "$0" | grep "/build$" > /dev/null) && etcd_build || true
back to top