etcd/build

50 lines
1.3 KiB
Plaintext
Raw Normal View History

2015-05-30 09:34:54 +03:00
#!/bin/sh -e
# set some environment variables
ORG_PATH="github.com/coreos"
REPO_PATH="${ORG_PATH}/etcd"
GIT_SHA=$(git rev-parse --short HEAD || echo "GitNotFound")
2016-06-21 22:44:11 +03:00
if [ ! -z "$FAILPOINTS" ]; then
GIT_SHA="$GIT_SHA"-FAILPOINTS
fi
# Set GO_LDFLAGS="-s" for building without symbols for debugging.
GO_LDFLAGS="$GO_LDFLAGS -X ${REPO_PATH}/version.GitSHA=${GIT_SHA}"
2016-10-15 00:21:20 +03:00
2016-06-21 22:44:11 +03:00
# enable/disable failpoints
toggle_failpoints() {
mode="$1"
2016-06-21 22:44:11 +03:00
if which gofail >/dev/null 2>&1; then
gofail "$mode" etcdserver/ mvcc/backend/
2016-06-21 22:44:11 +03:00
elif [ "$mode" != "disable" ]; then
echo "FAILPOINTS set but gofail not found"
exit 1
fi
}
toggle_failpoints_default() {
mode="disable"
if [ ! -z "$FAILPOINTS" ]; then mode="enable"; fi
toggle_failpoints "$mode"
}
etcd_build() {
out="bin"
if [ -n "${BINDIR}" ]; then out="${BINDIR}"; fi
toggle_failpoints_default
# Static compilation is useful when etcd is run in a container. $GO_BUILD_FLAGS is OK
# shellcheck disable=SC2086
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o "${out}/etcd" ${REPO_PATH} || return
# shellcheck disable=SC2086
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o "${out}/etcdctl" ${REPO_PATH}/etcdctl || return
}
toggle_failpoints_default
2016-06-21 22:44:11 +03:00
# only build when called directly, not sourced
if echo "$0" | grep "build$" >/dev/null; then
etcd_build
fi