From f44706c661985bbf96bf31798d3b995cba6649d8 Mon Sep 17 00:00:00 2001 From: Soren Mathiasen Date: Tue, 19 Apr 2016 15:15:56 +0200 Subject: [PATCH] Reduce the size of the binaries --- scripts/build.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 6681565c1..76ff6dad6 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -35,12 +35,18 @@ if ! which gox > /dev/null; then go get -u github.com/mitchellh/gox fi +LD_FLAGS="-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}" +# In relase mode we don't want debug information in the binary +if [[ -n "${TF_RELEASE}" ]]; then + LD_FLAGS="-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY} -s -w" +fi + # Build! echo "==> Building..." gox \ -os="${XC_OS}" \ -arch="${XC_ARCH}" \ - -ldflags "-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}" \ + -ldflags "${LD_FLAGS}" \ -output "pkg/{{.OS}}_{{.Arch}}/terraform-{{.Dir}}" \ $(go list ./... | grep -v /vendor/)