github.com/stackb/rules_proto@v0.0.0-20240221195024-5428336c51f1/pkg/plugin/builtin/cpp_plugin.go (about) 1 package builtin 2 3 import ( 4 "github.com/bazelbuild/bazel-gazelle/label" 5 "github.com/stackb/rules_proto/pkg/protoc" 6 ) 7 8 func init() { 9 protoc.Plugins().MustRegisterPlugin(&CppPlugin{}) 10 } 11 12 // CppPlugin implements Plugin for the built-in protoc C++ plugin. 13 type CppPlugin struct{} 14 15 // Name implements part of the Plugin interface. 16 func (p *CppPlugin) Name() string { 17 return "builtin:cpp" 18 } 19 20 // Configure implements part of the Plugin interface. 21 func (p *CppPlugin) Configure(ctx *protoc.PluginContext) *protoc.PluginConfiguration { 22 return &protoc.PluginConfiguration{ 23 Label: label.New("build_stack_rules_proto", "plugin/builtin", "cpp"), 24 Outputs: protoc.FlatMapFiles( 25 protoc.ImportPrefixRelativeFileNameWithExtensions(ctx.ProtoLibrary.StripImportPrefix(), ctx.Rel, ".pb.cc", ".pb.h"), 26 protoc.Always, 27 ctx.ProtoLibrary.Files()..., 28 ), 29 Options: ctx.PluginConfig.GetOptions(), 30 } 31 }