-
Notifications
You must be signed in to change notification settings - Fork 74
/
Makefile
59 lines (50 loc) · 1.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
GO_TEST_COVER_MODE ?= atomic
GO_UNIT_TEST_TIMEOUT ?= 60m
SHELL := /bin/bash
TOOL_DIR := $(CURDIR)/tools
TOOL_BIN_DIR := $(TOOL_DIR)/bin
TOOL_TEMP_DIR := $(TOOL_DIR)/tmp
GOPATH := $(shell go env GOPATH)
DIRS := \
$(TOOL_BIN_DIR) \
$(TOOL_TEMP_DIR)
export PATH := $(TOOL_BIN_DIR):$(PATH)
include $(wildcard $(TOOL_DIR)/*.mk)
PROTOS := \
**/*.proto
$(DIRS):
mkdir -p $@
PHONY+= init
init:
git submodule init
git submodule update
PHONY+= tools
tools: $(DIRS) $(PROTOC)
@go install \
google.golang.org/protobuf/cmd/protoc-gen-go
PHONY += protobuf
protobuf:
@for d in $$(find "crypto" -type f -name "*.proto"); do \
protoc -I$(GOPATH)/src --go_out=$(GOPATH)/src $(CURDIR)/$$d; \
done;
PHONY += coverage.txt
coverage.txt:
@echo "mode: $(GO_TEST_COVER_MODE)" > $@
PHONY += unit-test
unit-test: coverage.txt
@for d in $$(go list ./... | grep -v example | grep -v mocks | grep -v types); do \
set -o -x pipefail; \
go test -timeout $(GO_UNIT_TEST_TIMEOUT) -v -coverprofile=profile.out -covermode=$(GO_TEST_COVER_MODE) $$d 2>&1; \
if [ $$? -eq 0 ]; then \
if [ -f profile.out ]; then \
tail -n +2 profile.out | grep -v .pb.go >> coverage.txt; \
fi \
else \
echo "\033[31mFAIL\033[0m:\t$$d"; \
exit -1; \
fi \
done;
PHONY += tss-example
tss-example:
cd example/gg18 && go build
.PHONY: $(PHONY)