diff --git a/build b/build index db9022f4f23..b1fec53b087 100755 --- a/build +++ b/build @@ -4,6 +4,11 @@ ORG_PATH="github.com/coreos" REPO_PATH="${ORG_PATH}/etcd" export GO15VENDOREXPERIMENT="1" + +# Set GO_LDFLAGS="" for building with all symbols for debugging. +if [ -z "${GO_LDFLAGS+x}" ]; then GO_LDFLAGS="-s"; fi +GO_LDFLAGS="$GO_LDFLAGS -X ${REPO_PATH}/cmd/vendor/${REPO_PATH}/version.GitSHA=${GIT_SHA}" + eval $(go env) GIT_SHA=`git rev-parse --short HEAD || echo "GitNotFound"` if [ ! -z "$FAILPOINTS" ]; then @@ -31,8 +36,8 @@ 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 || return - CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "-s" -o ${out}/etcdctl ${REPO_PATH}/cmd/etcdctl || return + CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o ${out}/etcd ${REPO_PATH}/cmd/etcd || return + CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o ${out}/etcdctl ${REPO_PATH}/cmd/etcdctl || return } etcd_setup_gopath() { diff --git a/build.ps1 b/build.ps1 index 6e2155376a6..e614db96e43 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,6 +1,13 @@ $ORG_PATH="github.com/coreos" $REPO_PATH="$ORG_PATH/etcd" $PWD = $((Get-Item -Path ".\" -Verbose).FullName) +$GO_LDFLAGS="-s" + +# Set $Env:GO_LDFLAGS=" "(space) for building with all symbols for debugging. +if ($Env:GO_LDFLAGS.length -gt 0) { + $GO_LDFLAGS=$Env:GO_LDFLAGS +} +$GO_LDFLAGS="$GO_LDFLAGS -X $REPO_PATH/cmd/vendor/$REPO_PATH/version.GitSHA=$GIT_SHA" # rebuild symlinks echo "Rebuilding symlinks" @@ -41,5 +48,5 @@ if (-not $env:GOPATH) { $env:CGO_ENABLED = 0 $env:GO15VENDOREXPERIMENT = 1 $GIT_SHA="$(git rev-parse --short HEAD)" -go build -a -installsuffix cgo -ldflags "-s -X $REPO_PATH/cmd/vendor/$REPO_PATH/version.GitSHA=$GIT_SHA" -o bin\etcd.exe "$REPO_PATH\cmd\etcd" -go build -a -installsuffix cgo -ldflags "-s" -o bin\etcdctl.exe "$REPO_PATH\cmd\etcdctl" +go build -a -installsuffix cgo -ldflags $GO_LDFLAGS -o bin\etcd.exe "$REPO_PATH\cmd\etcd" +go build -a -installsuffix cgo -ldflags $GO_LDFLAGS -o bin\etcdctl.exe "$REPO_PATH\cmd\etcdctl"