blob: fa0f4ed98af0be221aba559710a0f502a3c153a0 [file] [log] [blame]
package python
import (
"github.com/bazelbuild/bazel-gazelle/rule"
)
const (
pyBinaryKind = "py_binary"
pyLibraryKind = "py_library"
pyTestKind = "py_test"
)
// 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 (*Python) Kinds() map[string]rule.KindInfo {
return pyKinds
}
var pyKinds = map[string]rule.KindInfo{
pyBinaryKind: {
MatchAny: true,
NonEmptyAttrs: map[string]bool{
"deps": true,
"main": true,
"srcs": true,
"imports": true,
"visibility": true,
},
SubstituteAttrs: map[string]bool{},
MergeableAttrs: map[string]bool{
"srcs": true,
},
ResolveAttrs: map[string]bool{
"deps": true,
},
},
pyLibraryKind: {
MatchAny: true,
NonEmptyAttrs: map[string]bool{
"deps": true,
"srcs": true,
"imports": true,
"visibility": true,
},
SubstituteAttrs: map[string]bool{},
MergeableAttrs: map[string]bool{
"srcs": true,
},
ResolveAttrs: map[string]bool{
"deps": true,
},
},
pyTestKind: {
MatchAny: true,
NonEmptyAttrs: map[string]bool{
"deps": true,
"main": true,
"srcs": true,
"imports": true,
"visibility": true,
},
SubstituteAttrs: map[string]bool{},
MergeableAttrs: map[string]bool{
"srcs": true,
},
ResolveAttrs: map[string]bool{
"deps": 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 (py *Python) Loads() []rule.LoadInfo {
return pyLoads
}
var pyLoads = []rule.LoadInfo{
{
Name: "@rules_python//python:defs.bzl",
Symbols: []string{
pyBinaryKind,
pyLibraryKind,
pyTestKind,
},
},
}