github.com/stackb/rules_proto@v0.0.0-20240221195024-5428336c51f1/pkg/protoc/proto_compiled_sources.go (about)

     1  package protoc
     2  
     3  import (
     4  	"github.com/bazelbuild/bazel-gazelle/rule"
     5  )
     6  
     7  func init() {
     8  	Rules().MustRegisterRule("stackb:rules_proto:proto_compiled_sources", &protoCompiledSources{})
     9  }
    10  
    11  // protoCompiledSources implements LanguageRule for the 'proto_compiled_sources' rule.
    12  type protoCompiledSources struct{}
    13  
    14  // KindInfo implements part of the LanguageRule interface.
    15  func (s *protoCompiledSources) KindInfo() rule.KindInfo {
    16  	return rule.KindInfo{
    17  		NonEmptyAttrs: map[string]bool{
    18  			"srcs": true,
    19  		},
    20  		MergeableAttrs: map[string]bool{
    21  			"srcs":            true,
    22  			"plugins":         true,
    23  			"output_mappings": true,
    24  			"options":         true,
    25  		},
    26  		SubstituteAttrs: map[string]bool{
    27  			"out": true,
    28  		},
    29  	}
    30  }
    31  
    32  // Name implements part of the LanguageRule interface.
    33  func (s *protoCompiledSources) Name() string {
    34  	return "proto_compiled_sources"
    35  }
    36  
    37  // LoadInfo implements part of the LanguageRule interface.
    38  func (s *protoCompiledSources) LoadInfo() rule.LoadInfo {
    39  	return rule.LoadInfo{
    40  		Name:    "@build_stack_rules_proto//rules:proto_compiled_sources.bzl",
    41  		Symbols: []string{"proto_compiled_sources"},
    42  	}
    43  }
    44  
    45  // ProvideRule implements part of the LanguageRule interface.
    46  func (s *protoCompiledSources) ProvideRule(cfg *LanguageRuleConfig, config *ProtocConfiguration) RuleProvider {
    47  	return &protoCompileRule{
    48  		kind:            "proto_compiled_sources",
    49  		nameSuffix:      "compiled_sources",
    50  		outputsAttrName: "srcs",
    51  		config:          config,
    52  		ruleConfig:      cfg,
    53  	}
    54  }