-
Notifications
You must be signed in to change notification settings - Fork 21
/
kinds.go
79 lines (71 loc) · 1.61 KB
/
kinds.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package gazelle
import (
"github.com/bazelbuild/bazel-gazelle/rule"
)
const (
TsProjectKind = "ts_project"
NpmPackageKind = "npm_package"
NpmLinkAllKind = "npm_link_all_packages"
RulesJsRepositoryName = "aspect_rules_js"
RulesTsRepositoryName = "aspect_rules_ts"
NpmRepositoryName = "npm"
)
// Kinds returns a map that maps rule names (kinds) and information on how to
// match and merge attributes that may be found in rules of those kinds.
func (*Language) Kinds() map[string]rule.KindInfo {
return tsKinds
}
var tsKinds = map[string]rule.KindInfo{
TsProjectKind: {
MatchAny: false,
NonEmptyAttrs: map[string]bool{
"srcs": true,
},
SubstituteAttrs: map[string]bool{},
MergeableAttrs: map[string]bool{
"srcs": true,
},
ResolveAttrs: map[string]bool{
"deps": true,
},
},
NpmLinkAllKind: {
MatchAny: true,
},
NpmPackageKind: {
MatchAny: false,
NonEmptyAttrs: map[string]bool{
"srcs": true,
},
SubstituteAttrs: map[string]bool{},
MergeableAttrs: map[string]bool{
"srcs": true,
},
},
}
// Loads returns .bzl files and symbols they define. Every rule generated by
// GenerateRules, now or in the past, should be loadable from one of these
// files.
func (ts *Language) Loads() []rule.LoadInfo {
return tsLoads
}
var tsLoads = []rule.LoadInfo{
{
Name: "@" + RulesTsRepositoryName + "//ts:defs.bzl",
Symbols: []string{
TsProjectKind,
},
},
{
Name: "@" + RulesJsRepositoryName + "//npm:defs.bzl",
Symbols: []string{
NpmPackageKind,
},
},
{
Name: "@" + NpmRepositoryName + "//:defs.bzl",
Symbols: []string{
NpmLinkAllKind,
},
},
}