github.com/rahart/packer@v0.12.2-0.20161229105310-282bb6ad370f/Makefile (about) 1 TEST?=$(shell go list ./... | grep -v vendor) 2 VET?=$(shell ls -d */ | grep -v vendor | grep -v website) 3 # Get the current full sha from git 4 GITSHA:=$(shell git rev-parse HEAD) 5 # Get the current local branch name from git (if we can, this may be blank) 6 GITBRANCH:=$(shell git symbolic-ref --short HEAD 2>/dev/null) 7 GOFMT_FILES?=$$(find . -not -path "./vendor/*" -name "*.go") 8 9 default: deps generate test dev 10 11 ci: deps test 12 13 release: deps test releasebin package ## Build a release build 14 15 bin: deps ## Build debug/test build 16 @echo "WARN: 'make bin' is for debug / test builds only. Use 'make release' for release builds." 17 @GO15VENDOREXPERIMENT=1 sh -c "$(CURDIR)/scripts/build.sh" 18 19 releasebin: deps 20 @grep 'const VersionPrerelease = "dev"' version/version.go > /dev/null ; if [ $$? -eq 0 ]; then \ 21 echo "ERROR: You must remove prerelease tags from version/version.go prior to release."; \ 22 exit 1; \ 23 fi 24 @GO15VENDOREXPERIMENT=1 sh -c "$(CURDIR)/scripts/build.sh" 25 26 package: 27 $(if $(VERSION),,@echo 'VERSION= needed to release; Use make package skip compilation'; exit 1) 28 @sh -c "$(CURDIR)/scripts/dist.sh $(VERSION)" 29 30 deps: 31 go get github.com/mitchellh/gox 32 go get golang.org/x/tools/cmd/stringer 33 go get github.com/kardianos/govendor 34 govendor sync 35 36 dev: deps ## Build and install a development build 37 @grep 'const VersionPrerelease = ""' version/version.go > /dev/null ; if [ $$? -eq 0 ]; then \ 38 echo "ERROR: You must add prerelease tags to version/version.go prior to making a dev build."; \ 39 exit 1; \ 40 fi 41 @PACKER_DEV=1 GO15VENDOREXPERIMENT=1 sh -c "$(CURDIR)/scripts/build.sh" 42 43 fmt: ## Format Go code 44 @gofmt -w -s $(GOFMT_FILES) 45 46 fmt-check: ## Check go code formatting 47 $(CURDIR)/scripts/gofmtcheck.sh $(GOFMT_FILES) 48 49 # Install js-beautify with npm install -g js-beautify 50 fmt-examples: 51 find examples -name *.json | xargs js-beautify -r -s 2 -n -eol "\n" 52 53 # generate runs `go generate` to build the dynamically generated 54 # source files. 55 generate: deps ## Generate dynamically generated code 56 go generate . 57 gofmt -w command/plugin.go 58 59 test: deps fmt-check ## Run unit tests 60 @go test $(TEST) $(TESTARGS) -timeout=2m 61 @go tool vet $(VET) ; if [ $$? -eq 1 ]; then \ 62 echo "ERROR: Vet found problems in the code."; \ 63 exit 1; \ 64 fi 65 66 # testacc runs acceptance tests 67 testacc: deps generate ## Run acceptance tests 68 @echo "WARN: Acceptance tests will take a long time to run and may cost money. Ctrl-C if you want to cancel." 69 PACKER_ACC=1 go test -v $(TEST) $(TESTARGS) -timeout=45m 70 71 testrace: deps ## Test for race conditions 72 @go test -race $(TEST) $(TESTARGS) -timeout=2m 73 74 updatedeps: 75 go get -u github.com/mitchellh/gox 76 go get -u golang.org/x/tools/cmd/stringer 77 @echo "INFO: Packer deps are managed by govendor. See CONTRIBUTING.md" 78 79 help: 80 @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' 81 82 .PHONY: bin checkversion ci default deps fmt fmt-examples generate releasebin test testacc testrace updatedeps