-
Notifications
You must be signed in to change notification settings - Fork 19
/
Makefile
52 lines (40 loc) · 1.18 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
SHELL := /bin/bash
BIN = $(CURDIR)/bin
BUILD_DIR = $(CURDIR)/build
GOPATH = $(HOME)/go
GOBIN = $(GOPATH)/bin
GO ?= GOGC=off $(shell which go)
# Printing
V = 0
Q = $(if $(filter 1,$V),,@)
M = $(shell printf "\033[34;1m▶\033[0m")
# Tools
$(BUILD_DIR):
@mkdir -p $@
$(BIN):
@mkdir -p $@
$(BIN)/%: | $(BIN) ; $(info $(M) building $(@F)…)
$Q GOBIN=$(BIN) $(GO) install $(shell $(GO) list -e -tags=tools -f '{{ join .Imports "\n" }}' ./tools | grep $(@F))
GOLANGCI_LINT = $(BIN)/golangci-lint
STRINGER = $(BIN)/stringer
GOIMPORTS = $(BIN)/goimports
# Targets
.PHONY: lint
lint: | $(GOLANGCI_LINT) ; $(info $(M) running golint…) @ ## Run the project linters
$Q $(GOLANGCI_LINT) run --max-issues-per-linter 10
.PHONY: test
test: ## Run all tests
$Q $(GO) test ./... -timeout 20s
.PHONY: fmt
fmt: ; $(info $(M) running gofmt…) @ ## Run gofmt on all source files
$Q $(GO) fmt $(PKGS)
.PHONY: clean
clean: ; $(info $(M) cleaning…) @ ## Cleanup everything
@rm -rf $(BIN)
@rm -rf $(BUILD)
.PHONY: build
build: test lint
.PHONY: help
help:
@grep -E '^[ a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'