constants.go 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /* Copyright 2017 The Bazel Authors. All rights reserved.
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. */
  12. package config
  13. const (
  14. // RulesGoRepoName is the canonical name of the rules_go repository. It must
  15. // match the workspace name in WORKSPACE.
  16. RulesGoRepoName = "io_bazel_rules_go"
  17. // DefaultLibName is the name of the default go_library rule in a Go
  18. // package directory. It must be consistent to DEFAULT_LIB in go/private/common.bf.
  19. DefaultLibName = "go_default_library"
  20. // DefaultTestName is a name of an internal test corresponding to
  21. // DefaultLibName. It does not need to be consistent to something but it
  22. // just needs to be unique in the Bazel package
  23. DefaultTestName = "go_default_test"
  24. // DefaultXTestName is a name of an external test corresponding to
  25. // DefaultLibName.
  26. DefaultXTestName = "go_default_xtest"
  27. // DefaultProtosName is the name of a filegroup created
  28. // whenever the library contains .pb.go files
  29. DefaultProtosName = "go_default_library_protos"
  30. // DefaultCgoLibName is the name of the default cgo_library rule in a Go package directory.
  31. DefaultCgoLibName = "cgo_default_library"
  32. // GrpcCompilerLabel is the label for the gRPC compiler plugin, used in the
  33. // "compilers" attribute of go_proto_library rules.
  34. GrpcCompilerLabel = "@io_bazel_rules_go//proto:go_grpc"
  35. // GazelleImportsKey is an internal attribute that lists imported packages
  36. // on generated rules. It is replaced with "deps" during import resolution.
  37. GazelleImportsKey = "_gazelle_imports"
  38. )
  39. // Language is the name of a programming langauge that Gazelle knows about.
  40. // This is used to specify import paths.
  41. type Language int
  42. const (
  43. // GoLang marks Go targets.
  44. GoLang Language = iota
  45. // ProtoLang marks protocol buffer targets.
  46. ProtoLang
  47. )
  48. func (l Language) String() string {
  49. switch l {
  50. case GoLang:
  51. return "go"
  52. case ProtoLang:
  53. return "proto"
  54. default:
  55. return "unknown"
  56. }
  57. }