From 066f02692ca4a9b8581e8eaa2a98edb27aefb036 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Tue, 19 Aug 2014 22:11:05 -0400 Subject: [PATCH] A few tweaks to the build setup & reported version --- .gitignore | 4 +++- Makefile | 39 +++++++++++++++++++++++++++------------ artifacts.go | 2 +- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 4a98ee0..45e951e 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,7 @@ _testmain.go *.exe *.test -*coverage.out +*.coverprofile *coverage.html /artifacts @@ -30,5 +30,7 @@ _testmain.go /.env /.gox-bootstrap +/.gox-install +/.deps /build/ /SHA256SUMS diff --git a/Makefile b/Makefile index efe683a..a8997f4 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,13 @@ SUBPACKAGES := \ $(PACKAGE)/path \ $(PACKAGE)/upload +COVERPROFILES := \ + artifact-coverage.coverprofile \ + env-coverage.coverprofile \ + logging-coverage.coverprofile \ + path-coverage.coverprofile \ + upload-coverage.coverprofile + VERSION_VAR := main.VersionString REPO_VERSION := $(shell git describe --always --dirty --tags) @@ -35,10 +42,10 @@ test-deps: test-race: $(GO) test -race $(GOBUILD_LDFLAGS) $(PACKAGE) $(SUBPACKAGES) -coverage.html: coverage.out +coverage.html: coverage.coverprofile $(GO) tool cover -html=$^ -o $@ -coverage.out: path-coverage.out upload-coverage.out env-coverage.out logging-coverage.out artifact-coverage.out +coverage.coverprofile: $(COVERPROFILES) $(GO) test -v -covermode=count -coverprofile=$@.tmp $(GOBUILD_LDFLAGS) $(PACKAGE) echo 'mode: count' > $@ grep -h -v 'mode: count' $@.tmp >> $@ @@ -46,19 +53,19 @@ coverage.out: path-coverage.out upload-coverage.out env-coverage.out logging-cov grep -h -v 'mode: count' $^ >> $@ $(GO) tool cover -func=$@ -path-coverage.out: +path-coverage.coverprofile: $(GO) test -v -covermode=count -coverprofile=$@ $(GOBUILD_LDFLAGS) $(PACKAGE)/path -upload-coverage.out: +upload-coverage.coverprofile: $(GO) test -v -covermode=count -coverprofile=$@ $(GOBUILD_LDFLAGS) $(PACKAGE)/upload -env-coverage.out: +env-coverage.coverprofile: $(GO) test -v -covermode=count -coverprofile=$@ $(GOBUILD_LDFLAGS) $(PACKAGE)/env -logging-coverage.out: +logging-coverage.coverprofile: $(GO) test -v -covermode=count -coverprofile=$@ $(GOBUILD_LDFLAGS) $(PACKAGE)/logging -artifact-coverage.out: +artifact-coverage.coverprofile: $(GO) test -v -covermode=count -coverprofile=$@ $(GOBUILD_LDFLAGS) $(PACKAGE)/artifact USAGE.txt: build @@ -74,7 +81,10 @@ USAGE.md: USAGE.txt UPLOAD_USAGE.txt $(shell git ls-files '*.go') $(GOX) -build-toolchain -osarch="$(GOX_OSARCH)" -verbose 2>&1 | tee $@ .PHONY: build -build: deps +build: deps .build + +.PHONY: .build +.build: $(GO) install $(GOBUILD_FLAGS) $(GOBUILD_LDFLAGS) $(PACKAGE) .PHONY: crossbuild @@ -82,14 +92,19 @@ crossbuild: deps .gox-bootstrap $(GOX) $(GOX_FLAGS) $(GOBUILD_FLAGS) $(GOBUILD_LDFLAGS) $(PACKAGE) .PHONY: deps -deps: - $(GODEP) restore - $(GO) get github.com/mitchellh/gox +deps: .gox-install .deps + +.deps: + $(GODEP) restore && touch $@ + +.gox-install: + $(GO) get -x github.com/mitchellh/gox > $@ .PHONY: clean clean: + rm -vf .gox-* .deps rm -vf $${GOPATH%%:*}/bin/artifacts - rm -vf coverage.html *coverage.out + rm -vf coverage.html *.coverprofile $(GO) clean $(PACKAGE) $(SUBPACKAGES) || true if [ -d $${GOPATH%%:*}/pkg ] ; then \ find $${GOPATH%%:*}/pkg -wholename '*travis-ci/artifacts*.a' | xargs rm -rfv || true; \ diff --git a/artifacts.go b/artifacts.go index ca6dbfe..4911709 100644 --- a/artifacts.go +++ b/artifacts.go @@ -118,7 +118,7 @@ func buildApp() *cli.App { app := cli.NewApp() app.Name = "artifacts" app.Usage = "manage your artifacts!" - app.Version = VersionString + app.Version = fmt.Sprintf("%s revision=%s", VersionString, RevisionString) app.Flags = []cli.Flag{ cli.StringFlag{ Name: "log-format, f",