Skip to content

Commit

Permalink
[proto] Allow multiple outputs from a proto compiler - fix import
Browse files Browse the repository at this point in the history
  • Loading branch information
jacqueline.lee committed Aug 11, 2023
1 parent 416dca0 commit 7b9eade
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
17 changes: 5 additions & 12 deletions tests/core/go_proto_library/compilers/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,17 @@ load(
)

go_library(
name = "dbenum",
srcs = ["dbenums.go"],
name = "protoc-gen-dbenum_lib",
srcs = [
"dbenums.go",
"main.go",
],
importpath = "github.com/bazelbuild/rules_go/tests/core/go_proto_library/compilers",
visibility = ["//visibility:private"],
deps = [
"@com_github_gogo_protobuf//proto",
"@com_github_gogo_protobuf//protoc-gen-gogo/descriptor",
"@com_github_gogo_protobuf//protoc-gen-gogo/generator",
],
)

go_library(
name = "protoc-gen-dbenum_lib",
srcs = ["main.go"],
importpath = "github.com/bazelbuild/rules_go/tests/core/go_proto_library/compilers",
visibility = ["//visibility:private"],
deps = [
"//tests/core/go_proto_library/compilers:dbenum",
"@com_github_gogo_protobuf//protoc-gen-gogo/plugin",
"@com_github_gogo_protobuf//vanity",
"@com_github_gogo_protobuf//vanity/command",
Expand Down
2 changes: 1 addition & 1 deletion tests/core/go_proto_library/compilers/dbenums.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dbenum
package main

import (
"bytes"
Expand Down
6 changes: 2 additions & 4 deletions tests/core/go_proto_library/compilers/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import (
plugin "github.com/gogo/protobuf/protoc-gen-gogo/plugin"
"github.com/gogo/protobuf/vanity"
"github.com/gogo/protobuf/vanity/command"

dbenum "github.com/bazelbuild/rules_go/tests/core/go_proto_library/compilers"
)

func main() {
Expand All @@ -21,7 +19,7 @@ func main() {

baseFiles := req.FileToGenerate

dbenumGenerator := dbenum.NewGenerator()
dbenumGenerator := NewGenerator()
req = onlyEnumFiles(req, baseFiles)
if len(req.FileToGenerate) > 0 {
resp = command.GeneratePlugin(req, dbenumGenerator, "_dbenum.pb.go")
Expand All @@ -36,7 +34,7 @@ func onlyEnumFiles(
dbEnumFiles := make(map[string]bool)
for _, file := range req.GetProtoFile() {
for _, enum := range file.EnumType {
if dbenum.HasDBEnum(enum.Value) {
if HasDBEnum(enum.Value) {
dbEnumFiles[*file.Name] = true
break
}
Expand Down

0 comments on commit 7b9eade

Please sign in to comment.