forked from michael1011/lightningtip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (43 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
53
54
55
56
57
58
PKG := github.com/michael1011/lightningtip
GOBUILD := GO111MODULE=on go build -v
GOINSTALL := GO111MODULE=on go install -v
GO_BIN := ${GOPATH}/bin
LINT_BIN := $(GO_BIN)/gometalinter.v2
HAVE_LINTER := $(shell command -v $(LINT_BIN) 2> /dev/null)
default: build
$(LINT_BIN):
@$(call print, "Fetching gometalinter.v2")
go get -u gopkg.in/alecthomas/gometalinter.v2
GREEN := "\\033[0;32m"
NC := "\\033[0m"
define print
echo $(GREEN)$1$(NC)
endef
LINT_LIST = $(shell go list -f '{{.Dir}}' ./...)
LINT = $(LINT_BIN) \
--disable-all \
--enable=gofmt \
--enable=vet \
--enable=golint \
--line-length=72 \
--deadline=4m $(LINT_LIST) 2>&1 | \
grep -v 'ALL_CAPS\|OP_' 2>&1 | \
tee /dev/stderr
# Building
build:
@$(call print, "Building lightningtip and tipreport")
$(GOBUILD) -o lightningtip $(PKG)
$(GOBUILD) -o tipreport $(PKG)/cmd/tipreport
install:
@$(call print, "Installing lightningtip and tipreport")
$(GOINSTALL) $(PKG)
$(GOINSTALL) $(PKG)/cmd/tipreport
# Utils
fmt:
@$(call print, "Formatting source")
gofmt -s -w .
lint: $(LINT_BIN)
@$(call print, "Linting source")
GO111MODULE=on go mod vendor
GO111MODULE=off $(LINT_BIN) --install 1> /dev/null
test -z "$$($(LINT))"