forked from stackb/rules_proto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cpp_plugin.go
31 lines (26 loc) · 892 Bytes
/
cpp_plugin.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
package builtin
import (
"github.com/bazelbuild/bazel-gazelle/label"
"github.com/stackb/rules_proto/pkg/protoc"
)
func init() {
protoc.Plugins().MustRegisterPlugin(&CppPlugin{})
}
// CppPlugin implements Plugin for the built-in protoc C++ plugin.
type CppPlugin struct{}
// Name implements part of the Plugin interface.
func (p *CppPlugin) Name() string {
return "builtin:cpp"
}
// Configure implements part of the Plugin interface.
func (p *CppPlugin) Configure(ctx *protoc.PluginContext) *protoc.PluginConfiguration {
return &protoc.PluginConfiguration{
Label: label.New("build_stack_rules_proto", "plugin/builtin", "cpp"),
Outputs: protoc.FlatMapFiles(
protoc.ImportPrefixRelativeFileNameWithExtensions(ctx.ProtoLibrary.StripImportPrefix(), ctx.Rel, ".pb.cc", ".pb.h"),
protoc.Always,
ctx.ProtoLibrary.Files()...,
),
Options: ctx.PluginConfig.GetOptions(),
}
}