-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
73 lines (52 loc) · 2.88 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
VERSION := $(shell git describe --tags --dirty)
BUILD := $(shell git rev-parse --short HEAD)
GOFILES := $(shell find . -type f -name '*.go')
LDFLAGS=-ldflags "-X=main.Version=$(VERSION) -X=main.Build=$(BUILD)"
.PHONY: all check ensure api test dep build clean clean-api veryclean help
all: check ensure api test build
check: ## Install all supporting dependencies like generators and dep.
$(info Checking system for required build/compile-time dependencies)
@bin/install_deps.sh
Gopkg.lock: Gopkg.toml
$(info Rebuilding Gopkg.lock)
@dep ensure -update
ensure: Gopkg.lock ## Ensure vendor directory is up to date
pkg/api/v1/todo-service.pb.go: api/proto/v1/todo-service.proto
$(info ... Generating Protobuffer Go files)
@protoc --proto_path=third_party --proto_path=api/proto/v1 --go_out=plugins=grpc:pkg/api/v1 todo-service.proto
api/swagger/v1/todo-service.swagger.json: api/proto/v1/todo-service.proto
$(info ... Generating Swagger Documentation)
@protoc --proto_path=third_party --proto_path=api/proto/v1 --swagger_out=logtostderr=true:api/swagger/v1 todo-service.proto
pkg/api/v1/todo-service.pb.gw.go: api/proto/v1/todo-service.proto
$(info ... Generating GRPC Gateway [REST] proxy)
@protoc --proto_path=third_party --proto_path=api/proto/v1 --grpc-gateway_out=logtostderr=true:pkg/api/v1 todo-service.proto
pkg/api/v1/todo-service.pb.gorm.go: api/proto/v1/todo-service.proto
$(info ... Generating GORM Protobuffer->ORM structures)
@protoc --proto_path=third_party --proto_path=api/proto/v1 --gorm_out=logtostderr=true:pkg/api/v1 todo-service.proto
api: pkg/api/v1/todo-service.pb.go api/swagger/v1/todo-service.swagger.json pkg/api/v1/todo-service.pb.gw.go pkg/api/v1/todo-service.pb.gorm.go ## Auto-generate grpc go sources
test: ## Run unit tests
$(info Running unit tests ...)
@go test ./pkg/service/v1
dep: ## Make sure all dependencies are up to date
@dep ensure
server: $(GOFILES)
$(info Compiling server)
@go build -v $(LDFLAGS) -o server ./cmd/server
client: $(GOFILES)
$(info Compiling client)
@go build -v $(LDFLAGS) -o client ./cmd/client
client-rest: $(GOFILES)
$(info Compiling REST client)
@go build -v $(LDFLAGS) -o client-rest ./cmd/client-rest
build: dep server client client-rest ## Build all binary artifacts
clean: ## Clean all build artifacts
$(info Cleaning all build artifacts)
@rm -rf server client client-rest
@go clean
clean-api: ## Remove all generated code and files. Regenerate with api target.
$(info Removing all generated code and files)
@rm -rfv pkg/api/v1/todo-service.pb.go api/swagger/v1/todo-service.swagger.json pkg/api/v1/todo-service.pb.gw.go pkg/api/v1/todo-service.pb.gorm.go
veryclean: clean clean-api ## Clean all caches and generated objects
@go clean -cache -testcache -modcache
help: ## Display this help screen
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'