build: re-enable building outside gopath
Have build return an error code if build fails and add a test to travis to confirm running build outside the gopath works.release-3.1
parent
28b797b538
commit
83dd121bae
|
@ -54,6 +54,7 @@ script:
|
|||
GOARCH=386 PASSES="build unit" ./test
|
||||
;;
|
||||
*)
|
||||
GOARCH="${TARGET}" ./build
|
||||
# test building out of gopath
|
||||
GO_BUILD_FLAGS="-a -v" GOPATH=/bad-go-path GOARCH="${TARGET}" ./build
|
||||
;;
|
||||
esac
|
||||
|
|
17
build
17
build
|
@ -1,8 +1,5 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
CDIR=$(cd `dirname "$0"` && pwd)
|
||||
cd "$CDIR"
|
||||
|
||||
# set some environment variables
|
||||
ORG_PATH="github.com/coreos"
|
||||
REPO_PATH="${ORG_PATH}/etcd"
|
||||
|
@ -34,11 +31,13 @@ etcd_build() {
|
|||
if [ -n "${BINDIR}" ]; then out="${BINDIR}"; 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/etcd
|
||||
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "-s" -o ${out}/etcdctl ${REPO_PATH}/cmd/etcdctl
|
||||
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/etcd || return
|
||||
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "-s" -o ${out}/etcdctl ${REPO_PATH}/cmd/etcdctl || return
|
||||
}
|
||||
|
||||
etcd_setup_gopath() {
|
||||
CDIR=$(cd `dirname "$0"` && pwd)
|
||||
cd "$CDIR"
|
||||
etcdGOPATH=${CDIR}/gopath
|
||||
# preserve old gopath to support building with unvendored tooling deps (e.g., gofail)
|
||||
export GOPATH=${etcdGOPATH}:$GOPATH
|
||||
|
@ -49,5 +48,9 @@ etcd_setup_gopath() {
|
|||
|
||||
toggle_failpoints
|
||||
|
||||
# don't build when sourced
|
||||
(echo "$0" | grep "/build$" > /dev/null) && etcd_build || true
|
||||
# only build when called directly, not sourced
|
||||
if echo "$0" | grep "build$" >/dev/null; then
|
||||
# force new gopath so builds outside of gopath work
|
||||
etcd_setup_gopath
|
||||
etcd_build
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue