-
-
Notifications
You must be signed in to change notification settings - Fork 661
/
BUILD.bazel
191 lines (177 loc) · 5.35 KB
/
BUILD.bazel
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
load(
"//go:def.bzl",
"TOOLS_NOGO",
)
load(
"//go/private:context.bzl",
"cgo_context_data",
"cgo_context_data_proxy",
"go_config",
"go_context_data",
)
load(
"//go/private/rules:info.bzl",
"go_info",
)
load(
"//go/private/rules:nogo.bzl",
"nogo",
)
load(
"//go/private/rules:stdlib.bzl",
"stdlib",
)
load(
"//go/private/tools:lines_sorted_test.bzl",
"lines_sorted_test",
)
# gazelle:prefix github.com/bazelbuild/rules_go
# gazelle:exclude tests
# gazelle:exclude third_party
# gazelle:exclude go/tools/builders
# gazelle:exclude go/tools/coverdata
# gazelle:exclude go/tools/fetch_repo
# gazelle:exclude go/tools/windows-testrunner
# gazelle:go_naming_convention import_alias
# TODO(jayconrod): add a gazelle rule so gazelle can be run automatically.
# It can't go here though, because it would break anything that depends on
# rules_go but not Gazelle, including our own go_bazel_tests.
stdlib(
name = "stdlib",
cgo_context_data = select({
"//go/platform:internal_cgo_off": None,
"//go/private:is_pure": None,
"//conditions:default": ":cgo_context_data",
}),
visibility = ["//visibility:public"],
)
# default_nogo is the nogo target that nogo references by default. It
# does not analyze anything, which means no binary is built or run
# at compile time.
filegroup(
name = "default_nogo",
visibility = ["//visibility:public"],
)
# tools_nogo includes all of the analysis passes in
# golang.org/x/tools/go/analysis/passes.
# This is not backward compatible, so use caution when depending on this --
# new analyses may discover issues in existing builds.
nogo(
name = "tools_nogo",
visibility = ["//visibility:public"],
deps = TOOLS_NOGO,
)
# go_context_data collects build options and is depended on by all Go targets.
# It may depend on cgo_context_data if CGo isn't disabled.
go_context_data(
name = "go_context_data",
cgo_context_data = select({
"//go/platform:internal_cgo_off": None,
"//go/private:is_pure": None,
"//conditions:default": ":cgo_context_data",
}),
coverdata = "//go/tools/coverdata",
go_config = ":go_config",
nogo = "@io_bazel_rules_nogo//:nogo",
stdlib = ":stdlib",
visibility = ["//visibility:public"],
)
# cgo_context_data collects information about the C/C++ toolchain.
# go_context_data depends if cgo is enabled in the target configuration.
cgo_context_data(
name = "cgo_context_data",
visibility = ["//visibility:private"],
)
# cgo_context_data_proxy depends on cgo_context_data if cgo is enabled and
# forwards its provider. Rule attributes may depend on this, since they cannot
# use select.
cgo_context_data_proxy(
name = "cgo_context_data_proxy",
actual = select({
"//go/platform:internal_cgo_off": None,
"//go/private:is_pure": None,
"//conditions:default": ":cgo_context_data",
}),
visibility = ["//visibility:public"],
)
# go_config collects information about build settings in the current
# configuration. go_context_data depends on this so that rules don't need
# to depend on all build settings directly.
go_config(
name = "go_config",
amd64 = select({
"//go/constraints/amd64:v2": "v2",
"//go/constraints/amd64:v3": "v3",
"//go/constraints/amd64:v4": "v4",
# The default is v1.
"//conditions:default": None,
}),
arm = select({
"//go/constraints/arm:5": "5",
"//go/constraints/arm:6": "6",
"//go/constraints/arm:7": "7",
"//conditions:default": None,
}),
cover_format = "//go/config:cover_format",
# Always include debug symbols with -c dbg.
debug = select({
"//go/private:is_compilation_mode_dbg": "//go/private:always_true",
"//conditions:default": "//go/config:debug",
}),
gc_goopts = "//go/config:gc_goopts",
gc_linkopts = "//go/config:gc_linkopts",
gotags = "//go/config:tags",
linkmode = "//go/config:linkmode",
msan = "//go/config:msan",
pgoprofile = "//go/config:pgoprofile",
pure = "//go/config:pure",
race = "//go/config:race",
stamp = select({
"//go/private:stamp": True,
"//conditions:default": False,
}),
static = "//go/config:static",
strip = select({
"//go/private:is_strip_always": True,
"//go/private:is_strip_sometimes_fastbuild": True,
"//conditions:default": False,
}),
visibility = ["//visibility:public"],
)
lines_sorted_test(
name = "contributors_sorted_test",
size = "small",
cmd = "grep -v '^#' $< | grep -v '^$$' >$@",
error_message = "Contributors must be sorted by first name",
file = "CONTRIBUTORS",
)
lines_sorted_test(
name = "authors_sorted_test",
size = "small",
cmd = "grep -v '^#' $< | grep -v '^$$' >$@",
error_message = "Authors must be sorted by first name",
file = "AUTHORS",
)
# AUTHORS is used as an anchor point for the directory in tests and the
# license can be consumed by depending projects.
exports_files([
"AUTHORS",
"LICENSE.txt",
])
go_info()
filegroup(
name = "all_files",
testonly = True,
srcs = [
"BUILD.bazel",
"MODULE.bazel",
"WORKSPACE",
"go.mod",
"go.sum",
"//extras:all_files",
"//go:all_files",
"//proto:all_files",
"//third_party:all_files",
],
visibility = ["//visibility:public"],
)