forked from stackb/rules_proto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
grpc_grpc_cpp.go
35 lines (29 loc) · 1.02 KB
/
grpc_grpc_cpp.go
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
package builtin
import (
"github.com/bazelbuild/bazel-gazelle/label"
"github.com/stackb/rules_proto/pkg/protoc"
)
func init() {
protoc.Plugins().MustRegisterPlugin(&GrpcGrpcCppPlugin{})
}
// GrpcGrpcCppPlugin implements Plugin for the built-in protoc python plugin.
type GrpcGrpcCppPlugin struct{}
// Name implements part of the Plugin interface.
func (p *GrpcGrpcCppPlugin) Name() string {
return "grpc:grpc:cpp"
}
// Configure implements part of the Plugin interface.
func (p *GrpcGrpcCppPlugin) Configure(ctx *protoc.PluginContext) *protoc.PluginConfiguration {
if !protoc.HasServices(ctx.ProtoLibrary.Files()...) {
return nil
}
return &protoc.PluginConfiguration{
Label: label.New("build_stack_rules_proto", "plugin/grpc/grpc", "protoc-gen-grpc-cpp"),
Outputs: protoc.FlatMapFiles(
protoc.ImportPrefixRelativeFileNameWithExtensions(ctx.ProtoLibrary.StripImportPrefix(), ctx.Rel, ".grpc.pb.cc", ".grpc.pb.h"),
protoc.HasService,
ctx.ProtoLibrary.Files()...,
),
Options: ctx.PluginConfig.GetOptions(),
}
}