forked from rai-project/dlframework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
63 lines (51 loc) · 3.28 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
all: generate
fmt: ## Formats code
go fmt ./...
install-deps: ## Install dependencies
go get -u github.com/jteeuwen/go-bindata/...
go get -u github.com/elazarl/go-bindata-assetfs/...
go get -u google.golang.org/grpc
go get -u github.com/gogo/protobuf/[email protected]
go get -u github.com/gogo/protobuf/[email protected]
go get -u github.com/golang/protobuf/protoc-gen-go
go get -u github.com/gogo/protobuf/[email protected]
go get -u github.com/gogo/protobuf/[email protected]
go get -u github.com/gogo/protobuf/[email protected]
go get -d github.com/grpc-ecosystem/grpc-gateway/[email protected]
go get -d github.com/grpc-ecosystem/grpc-gateway/[email protected]
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/go-swagger/go-swagger/cmd/swagger
go get -u github.com/mailru/easyjson
generate-proto: ## Generates Go, GRPC Gateway and Swagger code
rm -fr swagger.go
protoc --plugin=protoc-gen-go=${GOPATH}/bin/protoc-gen-go -I. -I${GOPATH}/pkg/mod/github.com/grpc-ecosystem/grpc-gateway\@v1.16.0/third_party/googleapis -I${GOPATH}/pkg/mod/github.com/gogo/protobuf\@v1.3.2/ --gogofaster_out=Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types,plugins=grpc:. registry.proto predictor.proto features.proto
protoc -I. -I${GOPATH}/pkg/mod/github.com/grpc-ecosystem/grpc-gateway\@v1.16.0/third_party/googleapis -I${GOPATH}/pkg/mod/github.com/gogo/protobuf\@v1.3.2/ --grpc-gateway_out=logtostderr=true:. registry.proto predictor.proto features.proto
protoc -I. -I${GOPATH}/pkg/mod/github.com/grpc-ecosystem/grpc-gateway\@v1.16.0/third_party/googleapis -I${GOPATH}/pkg/mod/github.com/gogo/protobuf\@v1.3.2/ --swagger_out=logtostderr=true:. registry.proto predictor.proto features.proto
jq -s '.[0] * .[1]' predictor.swagger.json registry.swagger.json features.swagger.json> dlframework.swagger.json
mv dlframework.swagger.json dlframework.swagger.json.tmp
jq -s '.[0] * .[1]' dlframework.swagger.json.tmp swagger_info.json > dlframework.swagger.json
rm -fr dlframework.swagger.json.tmp
rm -fr predictor.swagger.json registry.swagger.json features.swagger.json
go run scripts/includetext.go
gofmt -s -w *pb.go *pb.gw.go *pb_test.go swagger.go
generate: generate-proto generate-swagger
generate-swagger: clean-httpapi ## Generates Go Swagger code
mkdir -p httpapi
swagger generate server --principal models.User -f dlframework.swagger.json -t httpapi -A dlframework
swagger generate client --principal models.User -f dlframework.swagger.json -t httpapi -A dlframework
swagger generate support --principal models.User -f dlframework.swagger.json -t httpapi -A dlframework
gofmt -s -w httpapi
clean: clean-httpapi ## Deletes generated code
rm -fr *pb.go *pb.gw.go *pb_test.go swagger.go
clean-httpapi: ## Deletes the httpapi directory
rm -fr httpapi
install-proto: ## Installs protobuf (used by travis)
./scripts/install-protobuf.sh
travis: install-proto install-deps dep-ensure generate ## Travis builder
echo "building..."
go build ./...
help: ## Shows this help text
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
.PHONY: help
.DEFAULT_GOAL := generate