Faster dev builds (#2924)

This patch runs 'go install' instead of gox which runs 'go build' for
'make dev' and copies the binary into ./bin and ./pkg/${GOOS}_${GOARCH}
to mimick the previous behavior. This reduces the roundtrip times
for a dev build from 11 sec to 500ms if there weren't any changes.
pull/2987/head
Frank Schröder 8 years ago committed by GitHub
parent 3f43fc912c
commit b6ae9f187c

@ -7,6 +7,17 @@ GOTOOLS = \
TEST ?= ./... TEST ?= ./...
GOTAGS ?= consul GOTAGS ?= consul
GOFILES ?= $(shell go list $(TEST) | grep -v /vendor/) GOFILES ?= $(shell go list $(TEST) | grep -v /vendor/)
GOOS=$(shell go env GOOS)
GOARCH=$(shell go env GOARCH)
# Get the git commit
GIT_COMMIT=$(shell git rev-parse --short HEAD)
GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
GIT_DESCRIBE=$(shell git describe --tags --always)
GIT_IMPORT=github.com/hashicorp/consul/version
GOLDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY) -X $(GIT_IMPORT).GitDescribe=$(GIT_DESCRIBE)
export GOLDFLAGS
# all builds binaries for all targets # all builds binaries for all targets
all: bin all: bin
@ -16,8 +27,11 @@ bin: tools
@GOTAGS='$(GOTAGS)' sh -c "'$(CURDIR)/scripts/build.sh'" @GOTAGS='$(GOTAGS)' sh -c "'$(CURDIR)/scripts/build.sh'"
# dev creates binaries for testing locally - these are put into ./bin and $GOPATH # dev creates binaries for testing locally - these are put into ./bin and $GOPATH
dev: format dev:
@CONSUL_DEV=1 GOTAGS='$(GOTAGS)' sh -c "'$(CURDIR)/scripts/build.sh'" mkdir -p pkg/$(GOOS)_$(GOARCH)
go install -ldflags '$(GOLDFLAGS)' -tags '$(GOTAGS)'
cp $(GOPATH)/bin/consul bin
cp $(GOPATH)/bin/consul pkg/$(GOOS)_$(GOARCH)
# dist builds binaries for all platforms and packages them for distribution # dist builds binaries for all platforms and packages them for distribution
dist: dist:

@ -13,12 +13,6 @@ DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
# Change into that directory # Change into that directory
cd "$DIR" cd "$DIR"
# Get the git commit
GIT_COMMIT="$(git rev-parse --short HEAD)"
GIT_DIRTY="$(test -n "`git status --porcelain`" && echo "+CHANGES" || true)"
GIT_DESCRIBE="$(git describe --tags --always)"
GIT_IMPORT="github.com/hashicorp/consul/version"
# Determine the arch/os combos we're building for # Determine the arch/os combos we're building for
XC_ARCH=${XC_ARCH:-"386 amd64 arm"} XC_ARCH=${XC_ARCH:-"386 amd64 arm"}
XC_OS=${XC_OS:-"solaris darwin freebsd linux windows"} XC_OS=${XC_OS:-"solaris darwin freebsd linux windows"}
@ -41,7 +35,7 @@ echo "==> Building..."
-os="${XC_OS}" \ -os="${XC_OS}" \
-arch="${XC_ARCH}" \ -arch="${XC_ARCH}" \
-osarch="!darwin/arm" \ -osarch="!darwin/arm" \
-ldflags "-X ${GIT_IMPORT}.GitCommit='${GIT_COMMIT}${GIT_DIRTY}' -X ${GIT_IMPORT}.GitDescribe='${GIT_DESCRIBE}'" \ -ldflags "${GOLDFLAGS}" \
-output "pkg/{{.OS}}_{{.Arch}}/consul" \ -output "pkg/{{.OS}}_{{.Arch}}/consul" \
-tags="${GOTAGS}" \ -tags="${GOTAGS}" \
. .

Loading…
Cancel
Save