| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- #!/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")
- 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}/internal/version.GitSHA=${GIT_SHA}"
- # enable/disable failpoints
- toggle_failpoints() {
- mode="$1"
- if which gofail >/dev/null 2>&1; then
- gofail "$mode" etcdserver/ internal/mvcc/backend/
- elif [ "$mode" != "disable" ]; then
- echo "FAILPOINTS set but gofail not found"
- exit 1
- fi
- }
- etcd_setup_gopath() {
- echo "Setting GOPATH from vendor directory at 'gopath'"
- d=$(dirname "$0")
- CDIR=$(cd "$d" && pwd)
- cd "$CDIR"
- etcdGOPATH="${CDIR}/gopath"
- # preserve old gopath to support building with unvendored tooling deps (e.g., gofail)
- if [ -n "$GOPATH" ]; then
- GOPATH="$GOPATH"
- fi
- rm -rf "${etcdGOPATH:?}/"
- mkdir -p "${etcdGOPATH}/vendor" "${etcdGOPATH}/etcd_src/src/github.com/coreos"
- export GOPATH=${etcdGOPATH}/vendor:${etcdGOPATH}/etcd_src:$GOPATH
- ln -s "${CDIR}/vendor" "${etcdGOPATH}/vendor/src"
- ln -s "${CDIR}" "${etcdGOPATH}/etcd_src/src/github.com/coreos/etcd"
- #ln -s "${CDIR}/vendor" "${etcdGOPATH}/src"
- #ln -s "${CDIR}" "${etcdGOPATH}/src/github.com/coreos"
- }
- 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
- }
- tools_build() {
- out="bin"
- if [ -n "${BINDIR}" ]; then out="${BINDIR}"; fi
- # shellcheck disable=SC2039
- tools=(
- benchmark
- etcd-dump-db
- etcd-dump-logs
- functional-tester/etcd-agent
- functional-tester/etcd-tester
- functional-tester/etcd-runner
- local-tester/bridge
- )
- # shellcheck disable=SC2039
- for tool in "${tools[@]}"
- do
- # shellcheck disable=SC2086
- CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o "${out}/${tool}" "${REPO_PATH}/tools/${tool}" || return
- done
- }
- toggle_failpoints_default
- # only build when called directly, not sourced
- if echo "$0" | grep "build$" >/dev/null; then
- etcd_build
- fi
|