-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
61 lines (48 loc) · 2.3 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
#!make
PWD ?= $(shell pwd)
BUILD ?= $(PWD)/build
VERSION ?= $(shell git describe --tags --abbrev=0)
all: test build
.PHONY: lint
lint:
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
$(call print-target)
@golangci-lint run --config .golangci.yaml
.PHONY: fmt
fmt:
$(call print-target)
gofmt -s -w .
.PHONY: tidy
tidy:
$(call print-target)
go mod tidy
.PHONY: clean
clean:
$(call print-target)
@rm -rf $(BUILD)
@rm -rf $(PWD)/examples/**/*.pb.go
.PHONY: build
build: build-plugin build-examples
.PHONY: build-plugin
build-plugin: clean
$(call print-target)
@go build $(GOFLAGS) -ldflags="-X 'main.version=$(VERSION)'" -o $(BUILD)/protoc-gen-go-grpcmock ./cmd/protoc-gen-go-grpcmock
.PHONY: build-examples
build-examples: build-examples-testify build-examples-pegomock
.PHONY: build-examples-testify
build-examples-testify:
$(call print-target)
@cd examples/helloworld; protoc --go_out=testify --go_opt=paths=source_relative --go-grpc_out=testify --go-grpc_opt=paths=source_relative --plugin=$(BUILD)/protoc-gen-go-grpcmock --go-grpcmock_out=framework=testify,import_package=false:testify --go-grpcmock_opt=paths=source_relative helloworld.proto
@cd examples/routeguide; protoc --go_out=testify --go_opt=paths=source_relative --go-grpc_out=testify --go-grpc_opt=paths=source_relative --plugin=$(BUILD)/protoc-gen-go-grpcmock --go-grpcmock_out=framework=testify,import_package=false:testify --go-grpcmock_opt=paths=source_relative route_guide.proto
.PHONY: build-examples-pegomock
build-examples-pegomock:
$(call print-target)
@cd examples/helloworld; protoc --go_out=pegomock --go_opt=paths=source_relative --go-grpc_out=pegomock --go-grpc_opt=paths=source_relative --plugin=$(BUILD)/protoc-gen-go-grpcmock --go-grpcmock_out=framework=pegomock,import_package=false:pegomock --go-grpcmock_opt=paths=source_relative helloworld.proto
@cd examples/routeguide; protoc --go_out=pegomock --go_opt=paths=source_relative --go-grpc_out=pegomock --go-grpc_opt=paths=source_relative --plugin=$(BUILD)/protoc-gen-go-grpcmock --go-grpcmock_out=framework=pegomock,import_package=false:pegomock --go-grpcmock_opt=paths=source_relative route_guide.proto
.PHONY: test
test:
$(call print-target)
go test -race -cover ./... -timeout 60s
define print-target
@printf "Executing target: \033[36m$@\033[0m\n"
endef