-
Notifications
You must be signed in to change notification settings - Fork 150
/
proto_nodejs_library.go
54 lines (45 loc) · 1.54 KB
/
proto_nodejs_library.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package rules_nodejs
import (
"github.com/bazelbuild/bazel-gazelle/rule"
"github.com/stackb/rules_proto/pkg/protoc"
)
const (
ProtoNodeJsLibraryRuleName = "proto_nodejs_library"
ProtoNodeJsLibraryRuleSuffix = "_nodejs_library"
)
func init() {
protoc.Rules().MustRegisterRule("stackb:rules_proto:proto_nodejs_library", &protoNodeJsLibrary{})
}
// protoNodeJsLibrary implements LanguageRule for the 'proto_nodejs_library' rule from
// @rules_proto.
type protoNodeJsLibrary struct{}
// Name implements part of the LanguageRule interface.
func (s *protoNodeJsLibrary) Name() string {
return ProtoNodeJsLibraryRuleName
}
// KindInfo implements part of the LanguageRule interface.
func (s *protoNodeJsLibrary) KindInfo() rule.KindInfo {
return jsLibraryKindInfo
}
// LoadInfo implements part of the LanguageRule interface.
func (s *protoNodeJsLibrary) LoadInfo() rule.LoadInfo {
return rule.LoadInfo{
Name: "@build_stack_rules_proto//rules/nodejs:proto_nodejs_library.bzl",
Symbols: []string{ProtoNodeJsLibraryRuleName},
}
}
// ProvideRule implements part of the LanguageRule interface.
func (s *protoNodeJsLibrary) ProvideRule(cfg *protoc.LanguageRuleConfig, pc *protoc.ProtocConfiguration) protoc.RuleProvider {
outputs := pc.GetPluginOutputs("builtin:js:common")
if len(outputs) == 0 {
return nil
}
return &JsLibrary{
KindName: ProtoNodeJsLibraryRuleName,
RuleNameSuffix: ProtoNodeJsLibraryRuleSuffix,
Outputs: outputs,
RuleConfig: cfg,
Config: pc,
Resolver: protoc.ResolveDepsAttr("deps", true),
}
}