github.com/stackb/rules_proto@v0.0.0-20240221195024-5428336c51f1/pkg/plugin/akka/akka_grpc/protoc_gen_akka_grpc.go (about) 1 package akka_grpc 2 3 import ( 4 "path" 5 6 "github.com/bazelbuild/bazel-gazelle/label" 7 "github.com/stackb/rules_proto/pkg/protoc" 8 ) 9 10 const AkkaGrpcPluginName = "akka:akka-grpc:protoc-gen-akka-grpc" 11 12 func init() { 13 protoc.Plugins().MustRegisterPlugin(&ProtocGenAkkaGrpcPlugin{}) 14 } 15 16 // ProtocGenAkkaGrpcPlugin implements Plugin for the akka-grpc plugin. 17 type ProtocGenAkkaGrpcPlugin struct{} 18 19 // Name implements part of the Plugin interface. 20 func (p *ProtocGenAkkaGrpcPlugin) Name() string { 21 return AkkaGrpcPluginName 22 } 23 24 // Configure implements part of the Plugin interface. 25 func (p *ProtocGenAkkaGrpcPlugin) Configure(ctx *protoc.PluginContext) *protoc.PluginConfiguration { 26 if !protoc.HasServices(ctx.ProtoLibrary.Files()...) { 27 return nil 28 } 29 30 srcjar := ctx.ProtoLibrary.BaseName() + "_akka_grpc.srcjar" 31 if ctx.Rel != "" { 32 srcjar = path.Join(ctx.Rel, srcjar) 33 } 34 35 return &protoc.PluginConfiguration{ 36 Label: label.New("build_stack_rules_proto", "plugin/akka/akka-grpc", "protoc-gen-akka-grpc"), 37 Outputs: []string{srcjar}, 38 Options: ctx.PluginConfig.GetOptions(), 39 } 40 }