forked from hyperledger-archives/burrow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
148 lines (115 loc) · 3.92 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# ----------------------------------------------------------
# REQUIREMENTS
# - go installed locally
# - for build_docker: docker installed locally
# ----------------------------------------------------------
SHELL := /bin/bash
REPO := $(shell pwd)
GOFILES_NOVENDOR := $(shell find ${REPO} -type f -name '*.go' -not -path "${REPO}/vendor/*")
PACKAGES_NOVENDOR := $(shell go list github.com/hyperledger/burrow/... | grep -v /vendor/)
VERSION := $(shell go run ./util/version/cmd/main.go)
VERSION_MIN := $(shell echo ${VERSION} | cut -d . -f 1-2)
COMMIT_SHA := $(shell echo `git rev-parse --short --verify HEAD`)
DOCKER_NAMESPACE := quay.io/monax
.PHONY: greet
greet:
@echo "Hi! I'm the marmot that will help you with burrow v${VERSION}"
.PHONY: version
version:
@echo "${VERSION}"
### Formatting, linting and vetting
# check the code for style standards; currently enforces go formatting.
# display output first, then check for success
.PHONY: check
check:
@echo "Checking code for formatting style compliance."
@gofmt -l -d ${GOFILES_NOVENDOR}
@gofmt -l ${GOFILES_NOVENDOR} | read && echo && echo "Your marmot has found a problem with the formatting style of the code." 1>&2 && exit 1 || true
# Just fix it
.PHONY: fix
fix:
@goimports -l -w ${GOFILES_NOVENDOR}
# fmt runs gofmt -w on the code, modifying any files that do not match
# the style guide.
.PHONY: fmt
fmt:
@echo "Correcting any formatting style corrections."
@gofmt -l -w ${GOFILES_NOVENDOR}
# lint installs golint and prints recommendations for coding style.
lint:
@echo "Running lint checks."
go get -u github.com/golang/lint/golint
@for file in $(GOFILES_NOVENDOR); do \
echo; \
golint --set_exit_status $${file}; \
done
# vet runs extended compilation checks to find recommendations for
# suspicious code constructs.
.PHONY: vet
vet:
@echo "Running go vet."
@go vet ${PACKAGES_NOVENDOR}
# run the megacheck tool for code compliance
.PHONY: megacheck
megacheck:
@go get honnef.co/go/tools/cmd/megacheck
@for pkg in ${PACKAGES_NOVENDOR}; do megacheck "$$pkg"; done
### Dependency management for github.com/hyperledger/burrow
# erase vendor wipes the full vendor directory
.PHONY: erase_vendor
erase_vendor:
rm -rf ${REPO}/vendor/
# install vendor uses glide to install vendored dependencies
.PHONY: install_vendor
install_vendor:
go get github.com/Masterminds/glide
glide install
# Dumps Solidity interface contracts for SNatives
.PHONY: snatives
snatives:
@go run ./util/snatives/cmd/main.go
### Building github.com/hyperledger/burrow
# build all targets in github.com/hyperledger/burrow
.PHONY: build
build: check build_db build_client
# build all targets in github.com/hyperledger/burrow with checks for race conditions
.PHONY: build_race
build_race: check build_race_db build_race_client build_race_keys
# build burrow
.PHONY: build_db
build_db:
go build -o ${REPO}/target/burrow-${COMMIT_SHA} ./cmd/burrow
# build burrow-client
.PHONY: build_client
build_client:
go build -o ${REPO}/target/burrow-client-${COMMIT_SHA} ./client/cmd/burrow-client
# build burrow with checks for race conditions
.PHONY: build_race_db
build_race_db:
go build -race -o ${REPO}/target/burrow-${COMMIT_SHA} ./cmd/burrow
# build burrow-client with checks for race conditions
.PHONY: build_race_client
build_race_client:
go build -race -o ${REPO}/target/burrow-client-${COMMIT_SHA} ./client/cmd/burrow-client
### Testing github.com/hyperledger/burrow
# test burrow
.PHONY: test
test: check
@go test ${PACKAGES_NOVENDOR}
.PHONY: test_integration
test_integration:
@go test ./rpc/tendermint/test -tags integration
# test burrow with checks for race conditions
.PHONY: test_race
test_race: build_race
@go test -race ${PACKAGES_NOVENDOR}
### Build docker images for github.com/hyperledger/burrow
# build docker image for burrow
.PHONY: build_docker_db
build_docker_db: check
@scripts/build_tool.sh
### Clean up
# clean removes the target folder containing build artefacts
.PHONY: clean
clean:
-rm -r ./target