Skip to content

Commit

Permalink
Merge #6238: Smaller release binaries by stripping debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
apparentlymart committed Apr 19, 2016
2 parents 3213b3c + a153085 commit 26f0b80
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default: test vet

# bin generates the releaseable binaries for Terraform
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
# into ./bin/ as well as $GOPATH/bin
Expand Down
8 changes: 7 additions & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

Expand Down

0 comments on commit 26f0b80

Please sign in to comment.