Makefile: update .PHONY target (#4234)

Makefile: update .PHONY target

* Move .PHONY declarations near their targets

Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
Simon Pasquier 2018-06-11 17:51:28 +02:00 committed by Ben Kochie
parent 25e2d9f152
commit 45b8dea320
2 changed files with 19 additions and 5 deletions

View File

@ -27,8 +27,9 @@ ifdef DEBUG
bindata_flags = -debug bindata_flags = -debug
endif endif
.PHONY: assets
assets: assets:
@echo ">> writing assets" @echo ">> writing assets"
@$(GO) get -u github.com/jteeuwen/go-bindata/... @$(GO) get -u github.com/jteeuwen/go-bindata/...
@go-bindata $(bindata_flags) -pkg ui -o web/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' web/ui/templates/... web/ui/static/... @go-bindata $(bindata_flags) -pkg ui -o web/ui/bindata.go -ignore '(.*\.map|bootstrap\.js|bootstrap-theme\.css|bootstrap\.css)' web/ui/templates/... web/ui/static/...
@$(GO) fmt ./web/ui @$(GO) fmt ./web/ui

View File

@ -37,12 +37,15 @@ PREFIX ?= $(shell pwd)
BIN_DIR ?= $(shell pwd) BIN_DIR ?= $(shell pwd)
DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD)) DOCKER_IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
.PHONY: all
all: style staticcheck unused build test all: style staticcheck unused build test
.PHONY: style
style: style:
@echo ">> checking code style" @echo ">> checking code style"
! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^' ! $(GOFMT) -d $$(find . -path ./vendor -prune -o -name '*.go' -print) | grep '^'
.PHONY: check_license
check_license: check_license:
@echo ">> checking license header" @echo ">> checking license header"
@licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \ @licRes=$$(for file in $$(find . -type f -iname '*.go' ! -path './vendor/*') ; do \
@ -53,48 +56,58 @@ check_license:
exit 1; \ exit 1; \
fi fi
.PHONY: test-short
test-short: test-short:
@echo ">> running short tests" @echo ">> running short tests"
$(GO) test -short $(pkgs) $(GO) test -short $(pkgs)
.PHONY: test
test: test:
@echo ">> running all tests" @echo ">> running all tests"
$(GO) test -race $(pkgs) $(GO) test -race $(pkgs)
.PHONY: format
format: format:
@echo ">> formatting code" @echo ">> formatting code"
$(GO) fmt $(pkgs) $(GO) fmt $(pkgs)
.PHONY: vet
vet: vet:
@echo ">> vetting code" @echo ">> vetting code"
$(GO) vet $(pkgs) $(GO) vet $(pkgs)
.PHONY: staticcheck
staticcheck: $(STATICCHECK) staticcheck: $(STATICCHECK)
@echo ">> running staticcheck" @echo ">> running staticcheck"
$(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs) $(STATICCHECK) -ignore "$(STATICCHECK_IGNORE)" $(pkgs)
.PHONY: unused
unused: $(GOVENDOR) unused: $(GOVENDOR)
@echo ">> running check for unused packages" @echo ">> running check for unused packages"
@$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages' @$(GOVENDOR) list +unused | grep . && exit 1 || echo 'No unused packages'
.PHONY: build
build: promu build: promu
@echo ">> building binaries" @echo ">> building binaries"
$(PROMU) build --prefix $(PREFIX) $(PROMU) build --prefix $(PREFIX)
.PHONY: tarball
tarball: promu tarball: promu
@echo ">> building release tarball" @echo ">> building release tarball"
$(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR) $(PROMU) tarball --prefix $(PREFIX) $(BIN_DIR)
.PHONY: docker
docker: docker:
docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" . docker build -t "$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG)" .
.PHONY: promu
promu: promu:
GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu GOOS= GOARCH= $(GO) get -u github.com/prometheus/promu
$(FIRST_GOPATH)/bin/staticcheck: .PHONY: $(STATICCHECK)
$(STATICCHECK):
GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck GOOS= GOARCH= $(GO) get -u honnef.co/go/tools/cmd/staticcheck
$(FIRST_GOPATH)/bin/govendor: .PHONY: $(GOVENDOR)
$(GOVENDOR):
GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor GOOS= GOARCH= $(GO) get -u github.com/kardianos/govendor
.PHONY: all style check_license format build test vet assets tarball docker promu staticcheck $(FIRST_GOPATH)/bin/staticcheck govendor $(FIRST_GOPATH)/bin/govendor