github.com/0xKiwi/rules_go@v0.24.3/BUILD.bazel (about) 1 load( 2 "@io_bazel_rules_go//go/private:tools/lines_sorted_test.bzl", 3 "lines_sorted_test", 4 ) 5 load( 6 "@io_bazel_rules_go//go/private:rules/nogo.bzl", 7 "nogo", 8 ) 9 load( 10 "@io_bazel_rules_go//go/private:rules/info.bzl", 11 "go_info", 12 ) 13 load( 14 "@io_bazel_rules_go//go:def.bzl", 15 "TOOLS_NOGO", 16 ) 17 load( 18 "@io_bazel_rules_go//go/private:context.bzl", 19 "cgo_context_data", 20 "cgo_context_data_proxy", 21 "go_config", 22 "go_context_data", 23 ) 24 load( 25 "@io_bazel_rules_go//go/private:rules/stdlib.bzl", 26 "stdlib", 27 ) 28 29 # gazelle:prefix github.com/bazelbuild/rules_go 30 # gazelle:exclude tests 31 # gazelle:exclude third_party 32 # gazelle:exclude go/tools/builders 33 # gazelle:exclude go/tools/coverdata 34 # gazelle:exclude go/tools/fetch_repo 35 # gazelle:exclude go/tools/windows-testrunner 36 # gazelle:exclude go/tools/testwrapper 37 # gazelle:go_naming_convention import_alias 38 39 # TODO(jayconrod): add a gazelle rule so gazelle can be run automatically. 40 # It can't go here though, because it would break anything that depends on 41 # rules_go but not Gazelle, including our own go_bazel_tests. 42 43 stdlib( 44 name = "stdlib", 45 cgo_context_data = select({ 46 "//go/platform:internal_cgo_off": None, 47 "//conditions:default": ":cgo_context_data", 48 }), 49 visibility = ["//visibility:public"], 50 ) 51 52 # default_nogo is the nogo target that nogo references by default. It 53 # does not analyze anything, which means no binary is built or run 54 # at compile time. 55 nogo( 56 name = "default_nogo", 57 visibility = ["//visibility:public"], 58 ) 59 60 # tools_nogo includes all of the analysis passes in 61 # golang.org/x/tools/go/analysis/passes. 62 # This is not backward compatible, so use caution when depending on this -- 63 # new analyses may discover issues in existing builds. 64 nogo( 65 name = "tools_nogo", 66 visibility = ["//visibility:public"], 67 deps = TOOLS_NOGO, 68 ) 69 70 # go_context_data collects build options and is depended on by all Go targets. 71 # It may depend on cgo_context_data if CGo isn't disabled. 72 go_context_data( 73 name = "go_context_data", 74 cgo_context_data = select({ 75 "//go/platform:internal_cgo_off": None, 76 "//conditions:default": ":cgo_context_data", 77 }), 78 coverdata = "//go/tools/coverdata", 79 go_config = ":go_config", 80 nogo = "@io_bazel_rules_nogo//:nogo", 81 stdlib = ":stdlib", 82 visibility = ["//visibility:public"], 83 ) 84 85 # cgo_context_data collects information about the C/C++ toolchain. 86 # go_context_data depends if cgo is enabled in the target configuration. 87 cgo_context_data( 88 name = "cgo_context_data", 89 visibility = ["//visibility:private"], 90 ) 91 92 # cgo_context_data_proxy depends on cgo_context_data if cgo is enabled and 93 # forwards its provider. Rule attributes may depend on this, since they cannot 94 # use select. 95 cgo_context_data_proxy( 96 name = "cgo_context_data_proxy", 97 actual = select({ 98 "//go/platform:internal_cgo_off": None, 99 "//conditions:default": ":cgo_context_data", 100 }), 101 visibility = ["//visibility:public"], 102 ) 103 104 # go_config collects information about build settings in the current 105 # configuration. go_context_data depends on this so that rules don't need 106 # to depend on all build settings directly. 107 go_config( 108 name = "go_config", 109 debug = "//go/config:debug", 110 gotags = "//go/config:tags", 111 linkmode = "//go/config:linkmode", 112 msan = "//go/config:msan", 113 pure = "//go/config:pure", 114 race = "//go/config:race", 115 stamp = select({ 116 "//go/private:stamp": True, 117 "//conditions:default": False, 118 }), 119 static = "//go/config:static", 120 strip = "//go/config:strip", 121 visibility = ["//visibility:public"], 122 ) 123 124 lines_sorted_test( 125 name = "contributors_sorted_test", 126 size = "small", 127 cmd = "grep -v '^#' $< | grep -v '^$$' >$@", 128 error_message = "Contributors must be sorted by first name", 129 file = "CONTRIBUTORS", 130 ) 131 132 lines_sorted_test( 133 name = "authors_sorted_test", 134 size = "small", 135 cmd = "grep -v '^#' $< | grep -v '^$$' >$@", 136 error_message = "Authors must be sorted by first name", 137 file = "AUTHORS", 138 ) 139 140 # This could be any file, used as an anchor point for the directory in tests 141 exports_files(["AUTHORS"]) 142 143 go_info() 144 145 filegroup( 146 name = "all_files", 147 testonly = True, 148 srcs = [ 149 "BUILD.bazel", 150 "WORKSPACE", 151 "//extras:all_files", 152 "//go:all_files", 153 "//proto:all_files", 154 "//third_party:all_files", 155 ], 156 visibility = ["//visibility:public"], 157 )