-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
80 lines (61 loc) · 2.56 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
export GO111MODULE=on
export CHAIN33_PATH=$(shell go list -f {{.Dir}} github.com/33cn/chain33)
export PLUGIN_PATH=$(shell go list -f {{.Dir}} github.com/33cn/plugin)
PKG_LIST_VET := `go list ./... | grep -v "vendor" | grep -v plugin/dapp/evm/executor/vm/common/crypto/bn256`
PKG_LIST_INEFFASSIGN= `go list -f {{.Dir}} ./... | grep -v "vendor"`
BUILD_FLAGS = -ldflags "-X github.com/33cn/chain33/common/version.GitCommit=`git rev-parse --short=8 HEAD`"
.PHONY: default build
default: build
all: build
build: toolimport
go build ${BUILD_FLAGS} -v -o ycc
go build ${BUILD_FLAGS} -v -o ycc-cli github.com/yccproject/ycc/cli
#make updateplugin version=xxx
#单独更新plugin或chain33, version可以是tag或者commit哈希(tag必须是--vMajor.Minor.Patch--规范格式)
updateplugin:
@if [ -n "$(version)" ]; then \
go get github.com/33cn/plugin@${version}; \
else \
go get github.com/33cn/plugin@master;fi
updatechain33:
@if [ -n "$(version)" ]; then \
go get github.com/33cn/chain33@${version}; \
else \
go get github.com/33cn/chain33@master;fi
#make update version=xxx, 同时更新chain33和plugin, 两个项目必须有相同的tag(tag必须是--vMajor.Minor.Patch--规范格式)
update:updatechain33 updateplugin
vet:
@go vet ${PKG_LIST_VET}
ineffassign:
@golangci-lint run --no-config --issues-exit-code=1 --deadline=2m --disable-all --enable=ineffassign -n ${PKG_LIST_INEFFASSIGN}
linter: vet ineffassign ## Use gometalinter check code, ignore some unserious warning
@./golinter.sh "filter"
.PHONY: checkgofmt
checkgofmt: ## get all go files and run go fmt on them
@files=$$(find . -name '*.go' -not -path "./vendor/*" | xargs gofmt -l -s); if [ -n "$$files" ]; then \
echo "Error: 'make fmt' needs to be run on:"; \
echo "${files}"; \
exit 1; \
fi;
@files=$$(find . -name '*.go' -not -path "./vendor/*" | xargs goimports -l -w); if [ -n "$$files" ]; then \
echo "Error: 'make fmt' needs to be run on:"; \
echo "${files}"; \
exit 1; \
fi;
fmt_shell: ## check shell file
@find . -name '*.sh' -not -path "./vendor/*" | xargs shfmt -w -s -i 4 -ci -bn
fmt: fmt_shell ## go fmt
@go fmt ./...
@find . -name '*.go' -not -path "./vendor/*" | xargs goimports -l -w
buildtool: ## chain33 tool
@go build -o tool `go list -f {{.Dir}} github.com/33cn/chain33`/cmd/tools
toolimport: buildtool ## update plugin import
@./tool import --path "plugin" --packname "github.com/yccproject/ycc/plugin" --conf "plugin/plugin.toml"
clean:
@rm -rf datadir
@rm -rf logs
@rm -rf wallet
@rm -rf grpc33.log
@rm -rf ycc
@rm -rf ycc-cli
@rm -rf tool