-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
59 lines (44 loc) · 1.24 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
#!/usr/bin/env make
GOCMD=./cmd
GO=go
.PHONY: fmt vet test
MINER=sonmminer
HUB=sonmhub
CLI=sonmcli
all: vet fmt test build
build:
@echo "+ $@"
${GO} build -tags nocgo -o ${MINER} ${GOCMD}/miner
${GO} build -tags nocgo -o ${HUB} ${GOCMD}/hub
${GO} build -o ${CLI} ${GOCMD}/cli
install: build
cp ${MINER} /usr/bin/
cp ${HUB} /usr/bin/
cp ${CLI} /usr/bin/
vet:
@echo "+ $@"
@go vet $(PKGS)
fmt:
@echo "+ $@"
@test -z "$$(gofmt -s -l . 2>&1 | grep -v ^vendor/ | tee /dev/stderr)" || \
(echo >&2 "+ please format Go code with 'gofmt -s'" && false)
test:
@echo "+ $@"
@echo > coverage.txt
@set -e; for pkg in $(PKGS); do ${GO} test -coverprofile=profile.out $$pkg; \
if [ -f profile.out ]; then \
cat profile.out >> coverage.txt; rm profile.out; \
fi done;
@sed -ie '2!s/mode: set//;/^$$/d' coverage.txt
grpc:
protoc -I proto/hub/ proto/hub/hub.proto --go_out=plugins=grpc:proto/hub/
protoc -I proto/miner/ proto/miner/miner.proto --go_out=plugins=grpc:proto/miner/
coverage:
${GO} tool cover -func=coverage.txt
${GO} tool cover -func=coverage.txt -o funccoverage.txt
${GO} tool cover -html=coverage.txt -o coverage.html
clean:
rm coverage.txt || true
rm coverage.html || true
rm funccoverage.txt || true
rm ${MINER} ${HUB} ${CLI}