Skip to content

Commit

Permalink
Skipping files without messages
Browse files Browse the repository at this point in the history
  • Loading branch information
seriousben committed Apr 14, 2020
1 parent fd297ce commit b4dab3f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.PHONY: proto
proto:
cd e2e && protoc --go_out=. --go-json_out=logtostderr=true:. e2e.proto
mkdir -p build
go build -o build/protoc-gen-go-json .
export PATH=$(CURDIR)/build/:$$PATH && \
cd e2e && protoc --go_out=. --go-json_out=logtostderr=true,v=10:. *.proto
33 changes: 33 additions & 0 deletions e2e/e2e_service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions e2e/e2e_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
syntax = "proto3";

package e2e;

import "e2e.proto";

service E2E {
rpc Hello(Basic) returns (Basic) {}
}
5 changes: 5 additions & 0 deletions gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ func New(reg *descriptor.Registry, opts Options) *generator {
func (g *generator) Generate(targets []*descriptor.File) ([]*plugin.CodeGeneratorResponse_File, error) {
var files []*plugin.CodeGeneratorResponse_File
for _, file := range targets {
if len(file.Messages) == 0 {
glog.V(1).Infof("Skipping %s, no messages", file.GetName())
continue
}

glog.V(1).Infof("Processing %s", file.GetName())
code, err := g.generate(file)
if err != nil {
Expand Down

0 comments on commit b4dab3f

Please sign in to comment.