Merge #6238: Smaller release binaries by stripping debug info

This commit is contained in:
Martin Atkins 2016-04-19 09:52:02 -07:00
commit 26f0b803e7
2 changed files with 8 additions and 2 deletions

View File

@ -5,7 +5,7 @@ default: test vet
# bin generates the releaseable binaries for Terraform # bin generates the releaseable binaries for Terraform
bin: fmtcheck generate bin: fmtcheck generate
@sh -c "'$(CURDIR)/scripts/build.sh'" @TF_RELEASE=1 sh -c "'$(CURDIR)/scripts/build.sh'"
# dev creates binaries for testing Terraform locally. These are put # dev creates binaries for testing Terraform locally. These are put
# into ./bin/ as well as $GOPATH/bin # into ./bin/ as well as $GOPATH/bin

View File

@ -35,12 +35,18 @@ if ! which gox > /dev/null; then
go get -u github.com/mitchellh/gox go get -u github.com/mitchellh/gox
fi 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! # Build!
echo "==> Building..." echo "==> Building..."
gox \ gox \
-os="${XC_OS}" \ -os="${XC_OS}" \
-arch="${XC_ARCH}" \ -arch="${XC_ARCH}" \
-ldflags "-X main.GitCommit=${GIT_COMMIT}${GIT_DIRTY}" \ -ldflags "${LD_FLAGS}" \
-output "pkg/{{.OS}}_{{.Arch}}/terraform-{{.Dir}}" \ -output "pkg/{{.OS}}_{{.Arch}}/terraform-{{.Dir}}" \
$(go list ./... | grep -v /vendor/) $(go list ./... | grep -v /vendor/)