github.com/wolfd/bazel-gazelle@v0.14.0/internal/language/go/kinds.go (about) 1 /* Copyright 2018 The Bazel Authors. All rights reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 */ 15 16 package golang 17 18 import "github.com/bazelbuild/bazel-gazelle/internal/rule" 19 20 var goKinds = map[string]rule.KindInfo{ 21 "filegroup": { 22 NonEmptyAttrs: map[string]bool{"srcs": true}, 23 MergeableAttrs: map[string]bool{"srcs": true}, 24 }, 25 "go_binary": { 26 MatchAny: true, 27 NonEmptyAttrs: map[string]bool{ 28 "deps": true, 29 "embed": true, 30 "srcs": true, 31 }, 32 SubstituteAttrs: map[string]bool{"embed": true}, 33 MergeableAttrs: map[string]bool{ 34 "cgo": true, 35 "clinkopts": true, 36 "copts": true, 37 "embed": true, 38 "srcs": true, 39 }, 40 ResolveAttrs: map[string]bool{"deps": true}, 41 }, 42 "go_library": { 43 MatchAttrs: []string{"importpath"}, 44 NonEmptyAttrs: map[string]bool{ 45 "deps": true, 46 "embed": true, 47 "srcs": true, 48 }, 49 SubstituteAttrs: map[string]bool{ 50 "embed": true, 51 }, 52 MergeableAttrs: map[string]bool{ 53 "cgo": true, 54 "clinkopts": true, 55 "copts": true, 56 "embed": true, 57 "importmap": true, 58 "importpath": true, 59 "srcs": true, 60 }, 61 ResolveAttrs: map[string]bool{"deps": true}, 62 }, 63 "go_proto_library": { 64 MatchAttrs: []string{"importpath"}, 65 NonEmptyAttrs: map[string]bool{ 66 "deps": true, 67 "embed": true, 68 "proto": true, 69 "srcs": true, 70 }, 71 SubstituteAttrs: map[string]bool{"proto": true}, 72 MergeableAttrs: map[string]bool{ 73 "srcs": true, 74 "importpath": true, 75 "importmap": true, 76 "cgo": true, 77 "clinkopts": true, 78 "copts": true, 79 "embed": true, 80 "proto": true, 81 }, 82 ResolveAttrs: map[string]bool{"deps": true}, 83 }, 84 "go_repository": { 85 MatchAttrs: []string{"importpath"}, 86 NonEmptyAttrs: nil, // never empty 87 MergeableAttrs: map[string]bool{ 88 "commit": true, 89 "importpath": true, 90 "remote": true, 91 "sha256": true, 92 "strip_prefix": true, 93 "tag": true, 94 "type": true, 95 "urls": true, 96 "vcs": true, 97 }, 98 }, 99 "go_test": { 100 NonEmptyAttrs: map[string]bool{ 101 "deps": true, 102 "embed": true, 103 "srcs": true, 104 }, 105 MergeableAttrs: map[string]bool{ 106 "cgo": true, 107 "clinkopts": true, 108 "copts": true, 109 "embed": true, 110 "srcs": true, 111 }, 112 ResolveAttrs: map[string]bool{"deps": true}, 113 }, 114 } 115 116 var goLoads = []rule.LoadInfo{ 117 { 118 Name: "@io_bazel_rules_go//go:def.bzl", 119 Symbols: []string{ 120 "cgo_library", 121 "go_binary", 122 "go_library", 123 "go_prefix", 124 "go_repository", 125 "go_test", 126 }, 127 }, { 128 Name: "@io_bazel_rules_go//proto:def.bzl", 129 Symbols: []string{ 130 "go_grpc_library", 131 "go_proto_library", 132 }, 133 }, { 134 Name: "@bazel_gazelle//:deps.bzl", 135 Symbols: []string{ 136 "go_repository", 137 }, 138 After: []string{ 139 "go_rules_dependencies", 140 "go_register_toolchains", 141 "gazelle_dependencies", 142 }, 143 }, 144 } 145 146 func (_ *goLang) Kinds() map[string]rule.KindInfo { return goKinds } 147 func (_ *goLang) Loads() []rule.LoadInfo { return goLoads }