forked from ethereumproject/go-ethereum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
117 lines (92 loc) · 4.42 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
.DEFAULT_GOAL := build
BUILD_VERSION?=snapshot
SOURCE_FILES?=$$(go list ./... | grep -v /vendor/)
TEST_PATTERN?=.
TEST_OPTIONS?=-race
BINARY=bin
BUILD_TIME=`date +%FT%T%z`
COMMIT=`git log --pretty=format:'%h' -n 1`
# Choose to install geth with or without SputnikVM.
WITH_SVM?=1
LDFLAGS=-ldflags "-X main.Version="`git describe --tags`
setup: ## Install all the build and lint dependencies
go get -u github.com/alecthomas/gometalinter
go get -u github.com/golang/dep/...
go get -u github.com/pierrre/gotestcover
go get -u golang.org/x/tools/cmd/cover
dep ensure
gometalinter --install
build: cmd/abigen cmd/bootnode cmd/disasm cmd/ethtest cmd/evm cmd/gethrpctest cmd/rlpdump cmd/geth ## Build a local snapshot binary versions of all commands
@ls -ld $(BINARY)/*
cmd/geth: ## Build a local snapshot binary version of geth. Use WITH_SVM=0 to disable building with SputnikVM (default: WITH_SVM=1)
if [ ${WITH_SVM} == 1 ]; then ./scripts/build_sputnikvm.sh build ; else mkdir -p ./${BINARY} && go build ${LDFLAGS} -o ${BINARY}/geth ./cmd/geth ; fi
@echo "Done building geth."
@echo "Run \"$(BINARY)/geth\" to launch geth."
cmd/abigen: ## Build a local snapshot binary version of abigen.
mkdir -p ./${BINARY} && go build ${LDFLAGS} -o ${BINARY}/abigen ./cmd/abigen
@echo "Done building abigen."
@echo "Run \"$(BINARY)/abigen\" to launch abigen."
cmd/bootnode: ## Build a local snapshot of bootnode.
mkdir -p ./${BINARY} && go build ${LDFLAGS} -o ${BINARY}/bootnode ./cmd/bootnode
@echo "Done building bootnode."
@echo "Run \"$(BINARY)/bootnode\" to launch bootnode."
cmd/disasm: ## Build a local snapshot of disasm.
mkdir -p ./${BINARY} && go build ${LDFLAGS} -o ${BINARY}/disasm ./cmd/disasm
@echo "Done building disasm."
@echo "Run \"$(BINARY)/disasm\" to launch disasm."
cmd/ethtest: ## Build a local snapshot of ethtest.
mkdir -p ./${BINARY} && go build ${LDFLAGS} -o ${BINARY}/ethtest ./cmd/ethtest
@echo "Done building ethtest."
@echo "Run \"$(BINARY)/ethtest\" to launch ethtest."
cmd/evm: ## Build a local snapshot of evm.
mkdir -p ./${BINARY} && go build ${LDFLAGS} -o ${BINARY}/evm ./cmd/evm
@echo "Done building evm."
@echo "Run \"$(BINARY)/evm\" to launch evm."
cmd/gethrpctest: ## Build a local snapshot of gethrpctest.
mkdir -p ./${BINARY} && go build ${LDFLAGS} -o ${BINARY}/gethrpctest ./cmd/gethrpctest
@echo "Done building gethrpctest."
@echo "Run \"$(BINARY)/gethrpctest\" to launch gethrpctest."
cmd/rlpdump: ## Build a local snapshot of rlpdump.
mkdir -p ./${BINARY} && go build ${LDFLAGS} -o ${BINARY}/rlpdump ./cmd/rlpdump
@echo "Done building rlpdump."
@echo "Run \"$(BINARY)/rlpdump\" to launch rlpdump."
install: ## Install all packages to $GOPATH/bin
go install ./cmd/{abigen,bootnode,disasm,ethtest,evm,gethrpctest,rlpdump}
$(MAKE) install_geth
install_geth: ## Install geth to $GOPATH/bin. Use WITH_SVM=0 to disable building with SputnikVM (default: WITH_SVM=1)
$(info Installing $$GOPATH/bin/geth)
if [ ${WITH_SVM} == 1 ]; then ./scripts/build_sputnikvm.sh install ; else go install ${LDFLAGS} ./cmd/geth ; fi
fmt: ## gofmt and goimports all go files
find . -name '*.go' -not -wholename './vendor/*' -not -wholename './_vendor*' | while read -r file; do gofmt -w -s "$$file"; goimports -w "$$file"; done
ci: lint test ## Run all code checks and tests
lint: ## Run all the linters
gometalinter \
--tests \
--vendor \
--vendored-linters \
--disable=interfacer \
--disable=maligned \
--enable=gosimple \
--enable=staticcheck \
--enable=gofmt \
--enable=goimports \
--enable=lll \
--enable=misspell \
--cyclo-over=15 \
--dupl-threshold=100 \
--line-length=120 \
--deadline=360s \
./...
test: ## Run all the tests
echo 'mode: atomic' > coverage.txt && \
go list ./... | xargs -n1 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.tmp {} && \
tail -n +2 coverage.tmp >> coverage.txt' && \
rm coverage.tmp
cover: test ## Run all the tests and opens the coverage report
go tool cover -html=coverage.txt
clean: ## Remove local snapshot binary directory
if [ -d ${BINARY} ] ; then rm -rf ${BINARY} ; fi
# Absolutely awesome: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: setup test cover fmt lint ci build cmd/geth cmd/abigen cmd/bootnode cmd/disasm cmd/ethtest cmd/evm cmd/gethrlptest cmd/rlpdump install install_geth clean help static