-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
262 lines (203 loc) · 9.34 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#!/usr/bin/env bash
.PHONY: geth android ios geth-cross swarm evm all test clean
.PHONY: geth-linux geth-linux-386 geth-linux-amd64 geth-linux-mips64 geth-linux-mips64le
.PHONY: geth-linux-arm geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
.PHONY: geth-darwin geth-darwin-386 geth-darwin-amd64
.PHONY: geth-windows geth-windows-386 geth-windows-amd64
COMPANY=Didux
AUTHOR=go-didux
DIR=$(shell pwd)
PACKAGES=$(shell find ./src -type d -not -path '\./src')
PACKAGES_ETH=$(shell find src/blockchain/smilobft -type d -not -path '\src/blockchain/smilobft')
SRC_DIR="src/blockchain/smilobft"
GOBIN=$(shell pwd)/build/bin
GO?=1.12
build: clean
go build -o go-didux main.go
docker build --no-cache -t $(FULLDOCKERNAME) .
test: clean ## Run tests
go test ./src/blockchain/... -timeout=10m
test-c: clean ## Run tests with coverage
go test ./src/... -timeout=15m -cover
test-all: clean
$(foreach pkg,$(PACKAGES),\
go test $(pkg) -timeout=5m;)
test-race: clean ## Run tests with -race. Note: expected to fail, but look for "DATA RACE" failures specifically
go test ./src/... -timeout=5m -race
lint: clean ## Run linters. Use make install-linters first.
vendorcheck ./src/...
gometalinter --deadline=3m -j 2 --disable-all --tests --vendor \
-E deadcode \
-E errcheck \
-E gas \
-E goconst \
-E gofmt \
-E goimports \
-E golint \
-E ineffassign \
-E interfacer \
-E maligned \
-E megacheck \
-E misspell \
-E nakedret \
-E structcheck \
-E unconvert \
-E unparam \
-E varcheck \
-E vet \
./src/...
lint-eth: clean
src/blockchain/smilobft/build/env.sh go run ./src/blockchain/smilobft/build/ci.go lint
imports:
./src/blockchain/smilobft/build/goimports.sh
cover: ## Runs tests on ./src/ with HTML code coverage
@echo "mode: count" > coverage-all.out
$(foreach pkg,$(PACKAGES),\
go test -coverprofile=coverage.out $(pkg);\
tail -n +2 coverage.out >> coverage-all.out;)
coveralls: ## Runs tests on ./src/ with HTML code coverage
go get github.com/mattn/goveralls
@echo "mode: count" > coverage-all.out
$(foreach pkg,$(PACKAGES),\
go test -covermode=count -coverprofile=coverage.out $(pkg);\
tail -n +2 coverage.out >> coverage-all.out;)
$(GOPATH)/bin/goveralls -coverprofile=coverage-all.out -service=travis-ci -repotoken $(COVERALLS_TOKEN)
doc:
godoc2md go-didux/src/model > ./docs/model.md
godoc2md go-didux/src/server > ./docs/server.md
$(foreach pkg,$(PACKAGES_ETH),\
rm -rf $(PWD)/docs/$(pkg); mkdir -p $(PWD)/docs/$(pkg); \
godoc2md go-smilo/$(pkg) > $(PWD)/docs/$(pkg).md;)
install-linters: ## Install linters
go get -u github.com/FiloSottile/vendorcheck
go get -u gopkg.in/alecthomas/gometalinter.v2
go get -u golang.org/x/tools/cmd/goimports
go get -u github.com/mattn/goveralls
format: # Formats the code. Must have goimports installed (use make install-linters).
# This sorts imports by [stdlib, 3rdpart]
$(foreach pkg,$(PACKAGES),\
goimports -w -local go-smilo $(pkg);\
gofmt -s -w $(pkg);)
gofmt -s -w main.go
goimports -w -local go-smilo main.go
# ********* BEGIN GETH BUILD TASKS *********
all:
src/blockchain/smilobft/build/env.sh go run ./src/blockchain/smilobft/build/ci.go install
didux: clean
src/blockchain/smilobft/build/env.sh go run ./src/blockchain/smilobft/build/ci.go install
test-eth: eth
src/blockchain/smilobft/build/env.sh go run src/blockchain/smilobft/build/ci.go test
unlink:
sudo unlink /usr/local/bin/geth || true
geth-link: unlink eth
sudo ln -s /opt/gocode/src/go-smilo/build/bin/geth /usr/local/bin/geth || true
go-didux: geth
geth: eth
@echo "Done building."
@echo "Run \"$(GOBIN)/go-didux\" to launch go-didux."
go-didux: clean geth-linux-amd64 geth-linux-386 geth-darwin
@echo "Done building."
@echo "Run \"$(GOBIN)/go-didux\" to launch go-didux."
android:
# export ANDROID_NDK_HOME=~/Downloads/android-studio/plugins/android-ndk/ # or replace it with your NDK_HOME, see: https://developer.android.com/ndk/guides/index.html
src/blockchain/smilobft/build/env.sh go run src/blockchain/smilobft/build/ci.go aar --local
@echo "Done building."
@echo "Import \"$(GOBIN)/geth.aar\" to use the library."
ios:
src/blockchain/smilobft/build/env.sh go run src/blockchain/smilobft/build/ci.go xcode --local
@echo "Done building."
@echo "Import \"$(GOBIN)/Geth.framework\" to use the library."
clean:
rm -fr build/_workspace
rm -fr build/bin
# The devtools target installs tools required for 'go generate'.
# You need to put $GOBIN (or $GOPATH/bin) in your PATH to use 'go generate'.
devtools:
env GOBIN= go get -u github.com/golang/dep/cmd/dep
env GOBIN= go get -u golang.org/x/tools/cmd/stringer
env GOBIN= go get -u github.com/kevinburke/go-bindata/go-bindata
env GOBIN= go get -u github.com/fjl/gencodec
env GOBIN= go get -u github.com/golang/protobuf/protoc-gen-go
env GOBIN= go install ./src/blockchain/smilobft/cmd/abigen
@type "npm" 2> /dev/null || echo 'Please install node.js and npm'
@type "solc" 2> /dev/null || echo 'Please install solc'
@type "protoc" 2> /dev/null || echo 'Please install protoc'
generate:
src/blockchain/smilobft/build/env.sh go generate go-didux/src/blockchain/smilobft
src/blockchain/smilobft/build/env.sh go generate go-didux/src/blockchain/smilobft/internal/jsre/deps
src/blockchain/smilobft/build/env.sh go generate ./src/blockchain/smilobft/...
rename:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go rename
# Cross Compilation Targets (xgo)
geth-cross: geth-linux geth-darwin android ios
@echo "Full cross compilation done:"
@ls -ld $(GOBIN)/geth-*
geth-linux: geth-linux-386 geth-linux-amd64 geth-linux-arm geth-linux-mips64 geth-linux-mips64le rename
@echo "Linux cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-*
geth-linux-386:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=linux/386 -v ./$(SRC_DIR)/cmd/geth
@echo "Linux 386 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep 386
geth-linux-amd64:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=linux/amd64 -v ./$(SRC_DIR)/cmd/geth
@echo "Linux amd64 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep amd64
geth-linux-arm: geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
@echo "Linux ARM cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep arm
geth-linux-arm-5:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=linux/arm-5 -v ./$(SRC_DIR)/cmd/geth
@echo "Linux ARMv5 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep arm-5
geth-linux-arm-6:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=linux/arm-6 -v ./$(SRC_DIR)/cmd/geth
@echo "Linux ARMv6 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep arm-6
geth-linux-arm-7:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=linux/arm-7 -v ./$(SRC_DIR)/cmd/geth
@echo "Linux ARMv7 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep arm-7
geth-linux-arm64:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=linux/arm64 -v ./$(SRC_DIR)/cmd/geth
@echo "Linux ARM64 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep arm64
geth-linux-mips:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=linux/mips --ldflags '-extldflags "-static"' -v ./$(SRC_DIR)/cmd/geth
@echo "Linux MIPS cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep mips
geth-linux-mipsle:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=linux/mipsle --ldflags '-extldflags "-static"' -v ./$(SRC_DIR)/cmd/geth
@echo "Linux MIPSle cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep mipsle
geth-linux-mips64:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=linux/mips64 --ldflags '-extldflags "-static"' -v ./$(SRC_DIR)/cmd/geth
@echo "Linux MIPS64 cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep mips64
geth-linux-mips64le:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=linux/mips64le --ldflags '-extldflags "-static"' -v ./$(SRC_DIR)/cmd/geth
@echo "Linux MIPS64le cross compilation done:"
@ls -ld $(GOBIN)/geth-linux-* | grep mips64le
geth-darwin: geth-darwin-386 geth-darwin-amd64
@echo "Darwin cross compilation done:"
@ls -ld $(GOBIN)/geth-darwin-*
geth-darwin-386:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=darwin/386 -v ./$(SRC_DIR)/cmd/geth
@echo "Darwin 386 cross compilation done:"
@ls -ld $(GOBIN)/geth-darwin-* | grep 386
geth-darwin-amd64:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=darwin/amd64 -v ./$(SRC_DIR)/cmd/geth
@echo "Darwin amd64 cross compilation done:"
@ls -ld $(GOBIN)/geth-darwin-* | grep amd64
geth-windows: geth-windows-386 geth-windows-amd64
@echo "Windows cross compilation done:"
@ls -ld $(GOBIN)/geth-windows-*
geth-windows-386:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=windows/386 -v ./$(SRC_DIR)/cmd/geth
@echo "Windows 386 cross compilation done:"
@ls -ld $(GOBIN)/geth-windows-* | grep 386
geth-windows-amd64:
$(SRC_DIR)/build/env.sh go run $(SRC_DIR)/build/ci.go xgo -- --go=$(GO) --targets=windows/amd64 -v ./$(SRC_DIR)/cmd/geth
@echo "Windows amd64 cross compilation done:"
@ls -ld $(GOBIN)/geth-windows-* | grep amd64
# ********* END GETH BUILD TASKS *********