-
Notifications
You must be signed in to change notification settings - Fork 48
/
Makefile
68 lines (52 loc) · 1.54 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
59
60
61
62
63
64
65
66
67
68
PKG := github.com/lightninglabs/lndmon
ESCPKG := github.com\/lightninglabs\/lndmon
TOOLS_DIR := tools
LINT_PKG := github.com/golangci/golangci-lint/cmd/golangci-lint
GOIMPORTS_PKG := github.com/rinchsan/gosimports/cmd/gosimports
GO_BIN := ${GOPATH}/bin
LINT_BIN := $(GO_BIN)/golangci-lint
GOBUILD := go build -v
GOFILES_NOVENDOR = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
GOLIST := go list -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'
RM := rm -f
CP := cp
MAKE := make
DOCKER_TOOLS = docker run -v $$(pwd):/build lndmon-tools
LINT = $(LINT_BIN) run -v
default: build
all: lint build
# ============
# DEPENDENCIES
# ============
goimports:
@$(call print, "Installing goimports.")
cd $(TOOLS_DIR); go install -trimpath -tags=tools $(GOIMPORTS_PKG)
# ============
# INSTALLATION
# ============
build:
@$(call print, "Building lndmon.")
$(GOBUILD) $(PKG)/cmd/lndmon
# =========
# UTILITIES
# =========
docker-tools:
@$(call print, "Building tools docker image.")
docker build -q -t lndmon-tools $(TOOLS_DIR)
fmt: goimports
@$(call print, "Fixing imports.")
gosimports -w $(GOFILES_NOVENDOR)
@$(call print, "Formatting source.")
gofmt -l -w -s $(GOFILES_NOVENDOR)
lint: docker-tools
@$(call print, "Linting source.")
$(DOCKER_TOOLS) golangci-lint run -v $(LINT_WORKERS)
list:
@$(call print, "Listing commands.")
@$(MAKE) -qp | \
awk -F':' '/^[a-zA-Z0-9][^$$#\/\t=]*:([^=]|$$)/ {split($$1,A,/ /);for(i in A)print A[i]}' | \
grep -v Makefile | \
sort
clean:
@$(call print, "Cleaning source.$(NC)")
$(RM) ./lndmon