github.com/mmcquillan/packer@v1.1.1-0.20171009221028-c85cf0483a5d/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  GOOS=$(shell go env GOOS)
     9  GOARCH=$(shell go env GOARCH)
    10  GOPATH=$(shell go env GOPATH)
    11  
    12  # Get the git commit
    13  GIT_DIRTY=$(shell test -n "`git status --porcelain`" && echo "+CHANGES" || true)
    14  GIT_COMMIT=$(shell git rev-parse --short HEAD)
    15  GIT_IMPORT=github.com/hashicorp/packer/version
    16  GOLDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY)
    17  
    18  export GOLDFLAGS
    19  
    20  default: deps generate test dev
    21  
    22  ci: deps test
    23  
    24  release: deps test releasebin package ## Build a release build
    25  
    26  bin: deps ## Build debug/test build
    27  	@go get github.com/mitchellh/gox
    28  	@echo "WARN: 'make bin' is for debug / test builds only. Use 'make release' for release builds."
    29  	@sh -c "$(CURDIR)/scripts/build.sh"
    30  
    31  releasebin: deps
    32  	@go get github.com/mitchellh/gox
    33  	@grep 'const VersionPrerelease = "dev"' version/version.go > /dev/null ; if [ $$? -eq 0 ]; then \
    34  		echo "ERROR: You must remove prerelease tags from version/version.go prior to release."; \
    35  		exit 1; \
    36  	fi
    37  	@sh -c "$(CURDIR)/scripts/build.sh"
    38  
    39  package:
    40  	$(if $(VERSION),,@echo 'VERSION= needed to release; Use make package skip compilation'; exit 1)
    41  	@sh -c "$(CURDIR)/scripts/dist.sh $(VERSION)"
    42  
    43  deps:
    44  	@go get golang.org/x/tools/cmd/stringer
    45  	@go get github.com/kardianos/govendor
    46  	@govendor sync
    47  
    48  dev: deps ## Build and install a development build
    49  	@grep 'const VersionPrerelease = ""' version/version.go > /dev/null ; if [ $$? -eq 0 ]; then \
    50  		echo "ERROR: You must add prerelease tags to version/version.go prior to making a dev build."; \
    51  		exit 1; \
    52  	fi
    53  	@mkdir -p pkg/$(GOOS)_$(GOARCH)
    54  	@go install -ldflags '$(GOLDFLAGS)'
    55  	@cp $(GOPATH)/bin/packer bin
    56  	@cp $(GOPATH)/bin/packer pkg/$(GOOS)_$(GOARCH)
    57  
    58  fmt: ## Format Go code
    59  	@gofmt -w -s $(GOFMT_FILES)
    60  
    61  fmt-check: ## Check go code formatting
    62  	$(CURDIR)/scripts/gofmtcheck.sh $(GOFMT_FILES)
    63  
    64  fmt-docs:
    65  	@find ./website/source/docs -name "*.md" -exec pandoc --wrap auto --columns 79 --atx-headers -s -f "markdown_github+yaml_metadata_block" -t "markdown_github+yaml_metadata_block" {} -o {} \;
    66  
    67  # Install js-beautify with npm install -g js-beautify
    68  fmt-examples:
    69  	find examples -name *.json | xargs js-beautify -r -s 2 -n -eol "\n"
    70  
    71  # generate runs `go generate` to build the dynamically generated
    72  # source files.
    73  generate: deps ## Generate dynamically generated code
    74  	go generate .
    75  	gofmt -w command/plugin.go
    76  
    77  test: deps fmt-check ## Run unit tests
    78  	@go test $(TEST) $(TESTARGS) -timeout=2m
    79  	@go tool vet $(VET)  ; if [ $$? -eq 1 ]; then \
    80  		echo "ERROR: Vet found problems in the code."; \
    81  		exit 1; \
    82  	fi
    83  
    84  # testacc runs acceptance tests
    85  testacc: deps generate ## Run acceptance tests
    86  	@echo "WARN: Acceptance tests will take a long time to run and may cost money. Ctrl-C if you want to cancel."
    87  	PACKER_ACC=1 go test -v $(TEST) $(TESTARGS) -timeout=45m
    88  
    89  testrace: deps ## Test for race conditions
    90  	@go test -race $(TEST) $(TESTARGS) -timeout=2m
    91  
    92  updatedeps:
    93  	@echo "INFO: Packer deps are managed by govendor. See CONTRIBUTING.md"
    94  
    95  help:
    96  	@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
    97  
    98  .PHONY: bin checkversion ci default deps fmt fmt-docs fmt-examples generate releasebin test testacc testrace updatedeps