-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
80 lines (59 loc) · 1.68 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
export GO111MODULE=on
# The name of the executable (default is current directory name)
TARGET := $(shell echo $${PWD\#\#*/})
.DEFAULT_GOAL: $(TARGET)
# test runner (can be overriden by CI)
GOTEST ?= go test
# go source files, ignore vendor directory
SRC = $(shell find . -type f -name '*.go' -not -path "./vendor/*")
# protobuf sources
PROTO_SRCS := $(shell find . -name *.proto)
.PHONY: all build clean install uninstall fmt simplify check deps generate run proto
all: check build
$(TARGET): $(SRC)
@go build -o build/$(TARGET) -tags=jsoniter
build: $(TARGET)
@true
clean:
@go clean
@rm -rf build/
install: build
@cp build/$(TARGET) $(GOPATH)/bin/
uninstall: clean
@rm -f $$(which ${TARGET})
fmt:
@gofmt -l -w $(SRC)
simplify:
@gofmt -s -l -w $(SRC)
check:
@go vet ./...
deps:
ifeq ($(shell which easyjson), )
@echo "Installing dependency: easyjson"
@go get -u github.com/mailru/easyjson/...
endif
ifeq ($(shell which protoc-gen-go), )
@echo "Installing dependency: protoc-gen-go"
@go get -u github.com/golang/protobuf/protoc-gen-go
endif
ifeq ($(shell which protoc), )
$(error protoc is not installed. You must install it manually on https://developers.google.com/protocol-buffers/)
endif
proto: deps
@for PROTO in $(PROTO_SRCS); do \
protoc -I/usr/local/include -I. \
--go_out=plugins=grpc:. \
$$PROTO; \
done
generate: deps
$(eval GENERATE_SRCS := $(shell git --no-pager grep -wl "go:generate" -- "*.go" ":(exclude)vendor"))
@for GENERATE_SRC in $(GENERATE_SRCS); do \
go generate $$GENERATE_SRC; \
done
run: build
@./build/$(TARGET)
test: test-all
test-all:
@$(GOTEST) -v `go list ./... | grep -v test/e2e`
test-e2e:
@$(GOTEST) -v `go list ./test/e2e` $(FLAGS)