Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use buf tooling #2630

Merged
merged 1 commit into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .make/docs.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ config-docs-generate: $(FLAEX)
@$(FLAEX) >| ../docs/extensions/$(NAME)/configuration.md

.PHONY: grpc-docs-generate
grpc-docs-generate: ../docs/extensions/${NAME}/grpc.md
grpc-docs-generate: buf-generate
97 changes: 19 additions & 78 deletions .make/protobuf.mk
Original file line number Diff line number Diff line change
@@ -1,80 +1,21 @@
.PHONY: protoc-gen-openapiv2
protoc-gen-openapiv2:
GO111MODULE=off go get -v github.com/grpc-ecosystem/grpc-gateway/protoc-gen-openapiv2

.PHONY: protoc-deps
protoc-deps: $(BINGO)
@# #TODO: bingo creates symlinks from the -l option in the current directory
@# if no GOPATH and GOBIN is set, but they should reside inside .bingo
@# for now we move them manually
@cd .. && GOPATH="" GOBIN="" $(BINGO) get -l google.golang.org/protobuf/cmd/protoc-gen-go
@cd .. && mv protoc-gen-go .bingo/
@cd .. && GOPATH="" GOBIN="" $(BINGO) get -l github.com/asim/go-micro/cmd/protoc-gen-micro/v3
@cd .. && mv protoc-gen-micro .bingo/
@cd .. && GOPATH="" GOBIN="" $(BINGO) get -l github.com/owncloud/protoc-gen-microweb
@cd .. && mv protoc-gen-microweb .bingo/
@cd .. && GOPATH="" GOBIN="" $(BINGO) get -l github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2
@cd .. && mv protoc-gen-openapiv2 .bingo/
@cd .. && GOPATH="" GOBIN="" $(BINGO) get -l github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc
@cd .. && mv protoc-gen-doc .bingo/

.PHONY: buf-generate
buf-generate: $(BUF) protoc-deps
$(BUF) generate

.PHONY: protocolbuffers-protobuf
protocolbuffers-protobuf:
GO111MODULE=off go get -v github.com/protocolbuffers/protobuf || true

.PHONY: googleapis-protobuf
googleapis-protobuf:
GO111MODULE=off go get -v github.com/googleapis/googleapis || true

.PHONY: gen-deps
gen-deps: protoc-gen-openapiv2 protocolbuffers-protobuf googleapis-protobuf


.PHONY: $(PROTO_SRC)/${NAME}.pb.go
$(PROTO_SRC)/${NAME}.pb.go: $(BUF) gen-deps $(PROTOC_GEN_GO)
@echo "$(NAME): generating $(PROTO_SRC)/${NAME}.pb.go"
@$(BUF) protoc \
-I=$(PROTO_SRC)/ \
-I=$(GOPATH)/src/github.com/protocolbuffers/protobuf/src \
-I=$(GOPATH)/src/github.com/googleapis/googleapis \
-I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \
--plugin protoc-gen-go=$(PROTOC_GEN_GO) \
--go_out=$(PROTO_SRC) \
--go_opt=paths=source_relative \
$(PROTO_SRC)/${NAME}.proto

.PHONY: $(PROTO_SRC)/${NAME}.pb.micro.go
$(PROTO_SRC)/${NAME}.pb.micro.go: $(BUF) gen-deps $(PROTOC_GEN_MICRO)
@echo "$(NAME): generating $(PROTO_SRC)/${NAME}.pb.micro.go"
@$(BUF) protoc \
-I=$(PROTO_SRC)/ \
-I=$(GOPATH)/src/github.com/protocolbuffers/protobuf/src \
-I=$(GOPATH)/src/github.com/googleapis/googleapis \
-I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \
--plugin protoc-gen-micro=$(PROTOC_GEN_MICRO) \
--micro_out=logtostderr=true:$(PROTO_SRC) \
--micro_opt=paths=source_relative \
$(PROTO_SRC)/${NAME}.proto

.PHONY: $(PROTO_SRC)/${NAME}.pb.web.go
$(PROTO_SRC)/${NAME}.pb.web.go: $(BUF) gen-deps $(PROTOC_GEN_MICROWEB)
@echo "$(NAME): generating $(PROTO_SRC)/${NAME}.pb.web.go"
@$(BUF) protoc \
-I=$(PROTO_SRC)/ \
-I=$(GOPATH)/src/github.com/protocolbuffers/protobuf/src \
-I=$(GOPATH)/src/github.com/googleapis/googleapis \
-I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \
--plugin protoc-gen-microweb=$(PROTOC_GEN_MICROWEB) \
--microweb_out=logtostderr=true:$(PROTO_SRC) \
--microweb_opt=paths=source_relative \
$(PROTO_SRC)/${NAME}.proto

.PHONY: $(PROTO_SRC)/${NAME}.swagger.json
$(PROTO_SRC)/${NAME}.swagger.json: $(BUF) gen-deps $(PROTOC_GEN_OPENAPIV2)
@echo "$(NAME): generating $(PROTO_SRC)/${NAME}.swagger.json"
@$(BUF) protoc \
-I=$(PROTO_SRC)/ \
-I=$(GOPATH)/src/github.com/protocolbuffers/protobuf/src \
-I=$(GOPATH)/src/github.com/googleapis/googleapis \
-I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \
--plugin protoc-gen-openapiv2=$(PROTOC_GEN_OPENAPIV2) \
--openapiv2_out=logtostderr=true:$(PROTO_SRC)/ \
$(PROTO_SRC)/${NAME}.proto

.PHONY: ../docs/extensions/${NAME}/grpc.md
../docs/extensions/${NAME}/grpc.md: $(BUF) gen-deps $(PROTOC_GEN_DOC)
@echo "$(NAME): generating ../docs/extensions/${NAME}/grpc.md"
@$(BUF) protoc \
-I=$(PROTO_SRC)/ \
-I=$(GOPATH)/src/github.com/protocolbuffers/protobuf/src \
-I=$(GOPATH)/src/github.com/googleapis/googleapis \
-I=$(GOPATH)/src/github.com/grpc-ecosystem/grpc-gateway \
--plugin protoc-gen-doc=$(PROTOC_GEN_DOC) \
--doc_opt=./templates/GRPC.tmpl,grpc.md \
--doc_out=../docs/extensions/${NAME} \
$(PROTO_SRC)/${NAME}.proto
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ protobuf:

.PHONY: bingo-update
bingo-update: $(BINGO)
$(BINGO) get -u
$(BINGO) get -l -u

CHANGELOG_VERSION =

Expand Down
6 changes: 1 addition & 5 deletions accounts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,4 @@ PROTO_SRC := pkg/proto/$(PROTO_VERSION)
include ../.make/protobuf.mk

.PHONY: protobuf
protobuf: $(PROTO_SRC)/${NAME}.pb.go \
$(PROTO_SRC)/${NAME}.pb.micro.go \
$(PROTO_SRC)/${NAME}.pb.web.go \
$(PROTO_SRC)/${NAME}.swagger.json \
../docs/extensions/${NAME}/grpc.md
protobuf: buf-generate
29 changes: 29 additions & 0 deletions accounts/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: v1
plugins:
- name: go
path: ../.bingo/protoc-gen-go
out: pkg/
opt:
- paths=source_relative

- name: micro
path: ../.bingo/protoc-gen-micro
out: pkg/
opt:
- paths=source_relative

- name: microweb
path: ../.bingo/protoc-gen-microweb
out: pkg/
opt:
- paths=source_relative

- name: openapiv2
path: ../.bingo/protoc-gen-openapiv2
out: pkg/

- name: doc
path: ../.bingo/protoc-gen-doc
out: ../docs/extensions/accounts
opt:
- ./templates/GRPC.tmpl,grpc.md
17 changes: 17 additions & 0 deletions accounts/buf.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by buf. DO NOT EDIT.
version: v1
deps:
- remote: buf.build
owner: googleapis
repository: googleapis
branch: main
commit: ca45b9d9c51849e898845743a28b0eb0
digest: b1--B2JdvzLV2KI5pYMG9AHJHFGznqXfZKjKwcqBuXhGgw=
create_time: 2021-10-14T15:09:30.598677Z
- remote: buf.build
owner: grpc-ecosystem
repository: grpc-gateway
branch: main
commit: 462ede5f3dee45569df6317bda220b1b
digest: b1-4FNKWjnS2yafyeOdqW8u-s7w1pJBHjz0Z6CbOL-Ipk0=
create_time: 2021-10-14T01:55:03.476639Z
10 changes: 10 additions & 0 deletions accounts/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: v1
lint:
use:
- DEFAULT
deps:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
breaking:
use:
- FILE
Loading