From 03e82687d6c3a7b1e9af44a4ff5f9c8463f479a9 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Wed, 6 Feb 2019 09:41:39 +0100 Subject: [PATCH] build.sh: only set git commit info for dev builds This commit fixes a problem where `make bin` would strip of any prerelease info. --- scripts/build.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index bdef1111f..72af007ee 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -26,9 +26,12 @@ rm -rf pkg/* mkdir -p bin/ # If its dev mode, only build for ourself -if [ "${TF_DEV}x" != "x" ]; then +if [[ -n "${TF_DEV}" ]]; then XC_OS=$(go env GOOS) XC_ARCH=$(go env GOARCH) + + # Allow LD_FLAGS to be appended during development compilations + LD_FLAGS="-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} $LD_FLAGS" fi if ! which gox > /dev/null; then @@ -36,15 +39,12 @@ if ! which gox > /dev/null; then go get -u github.com/mitchellh/gox fi -# instruct gox to build statically linked binaries +# Instruct gox to build statically linked binaries export CGO_ENABLED=0 -# Allow LD_FLAGS to be appended during development compilations -LD_FLAGS="-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} $LD_FLAGS" - # In release mode we don't want debug information in the binary if [[ -n "${TF_RELEASE}" ]]; then - LD_FLAGS="-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -X github.com/hashicorp/terraform/version.Prerelease= -s -w" + LD_FLAGS="-s -w" fi # Ensure all remote modules are downloaded and cached before build so that