This repository has been archived by the owner on Jun 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMakefile
81 lines (58 loc) · 2.45 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
69
70
71
72
73
74
75
76
77
78
79
80
81
NAME=lino
GOPATH ?= $(shell $(GO) env GOPATH)
COMMIT := $(shell git --no-pager describe --tags --always --dirty)
PACKAGES=$(shell go list ./... | grep -v '/vendor/')
LD_FLAGS := "-X github.com/lino-network/lino/app.Version=$(COMMIT) -X github.com/cosmos/cosmos-sdk/types.DBBackend=cleveldb"
GO_TAGS := "tendermint cgo cleveldb"
CGO_LDFLAGS := "-lsnappy"
GO111MODULE = on
all: get_tools install build test
get_tools:
cd scripts && ./install_cleveldb.sh
update_mocks:
GO111MODULE=$(GO111MODULE) go generate ./...
_raw_build_cmd:
GO111MODULE=$(GO111MODULE) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=1 go build -ldflags $(LD_FLAGS) -tags $(GO_TAGS) -o bin/linod cmd/lino/main.go
GO111MODULE=$(GO111MODULE) CGO_ENABLED=0 go build -ldflags $(LD_FLAGS) -o bin/linocli cmd/linocli/main.go
_raw_install_cmd:
cd cmd/lino && GO111MODULE=$(GO111MODULE) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=1 go install -ldflags $(LD_FLAGS) -tags $(GO_TAGS)
cd cmd/linocli && GO111MODULE=$(GO111MODULE) CGO_ENABLED=0 go install -ldflags $(LD_FLAGS)
build:
make _raw_build_cmd
install:
make _raw_install_cmd
install_cli:
cd cmd/linocli && GO111MODULE=$(GO111MODULE) CGO_ENABLED=0 go install -ldflags $(LD_FLAGS)
build_cli:
GO111MODULE=$(GO111MODULE) CGO_ENABLED=0 go build -ldflags $(LD_FLAGS) -o bin/linocli cmd/linocli/main.go
test:
GO111MODULE=$(GO111MODULE) CGO_LDFLAGS=$(CGO_LDFLAGS) CGO_ENABLED=1 go test -ldflags $(LD_FLAGS) -tags $(GO_TAGS) ./... -timeout 600s
benchmark:
@go test -bench=. $(PACKAGES)
docker-build:
docker build -t $(NAME) .
docker-build-nc:
docker build --no-cache -t $(NAME) .
docker-run:
docker run --name=$(NAME) -it $(NAME)
docker-up: docker-build docker-run
docker-clean:
docker stop $(NAME)
docker rm $(NAME)
# lint
GOLANGCI_LINT_VERSION := v1.17.1
GOLANGCI_LINT_HASHSUM := f5fa647a12f658924d9f7d6b9628d505ab118e8e049e43272de6526053ebe08d
get_golangci_lint:
cd scripts && bash install-golangci-lint.sh $(GOPATH)/bin $(GOLANGCI_LINT_VERSION) $(GOLANGCI_LINT_HASHSUM)
lint:
GO111MODULE=$(GO111MODULE) golangci-lint run
GO111MODULE=$(GO111MODULE) go mod verify
GO111MODULE=$(GO111MODULE) go mod tidy
lint-fix:
@echo "--> Running linter auto fix"
GO111MODULE=$(GO111MODULE) golangci-lint run --fix
GO111MODULE=$(GO111MODULE) find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" | xargs gofmt -d -s
GO111MODULE=$(GO111MODULE) go mod verify
GO111MODULE=$(GO111MODULE) go mod tidy
.PHONY: lint lint-fix
.PHONY: all get_tools install build test