forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BUILD.bazel
197 lines (185 loc) · 9.76 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
192
193
194
195
196
197
load("@bazel_gazelle//:def.bzl", "gazelle")
# The following directives inform gazelle how to auto-generate BUILD.bazel
# files throughout the repo. By including them here, we can run gazelle using
# `bazel run //:gazelle` instead of invoking gazelle directly.
#
# NB: Be sure to re-generate BUILD.bazel files if any of the directives below
# are changed.
# Define the gazelle prefix and what the autogenerated BUILD files should be
# named as.
#
# gazelle:prefix github.com/cockroachdb/cockroach
# gazelle:build_file_name BUILD.bazel
# gazelle:build_tags bazel,crdb_test,crdb_test_off
# Enable protobuf generation.
#
# gazelle:proto package
# gazelle:proto_group go_package
# gazelle:go_proto_compilers //pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler
# gazelle:go_grpc_compilers //pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_grpc_compiler
# Gazelle needs the following resolve hints.
#
# gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/runtime @com_github_grpc_ecosystem_grpc_gateway//runtime:go_default_library
# gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/utilities @com_github_grpc_ecosystem_grpc_gateway//utilities:go_default_library
# gazelle:resolve go github.com/grpc-ecosystem/grpc-gateway/internal @com_github_grpc_ecosystem_grpc_gateway//internal
# gazelle:resolve proto proto errorspb/errors.proto @com_github_cockroachdb_errors//errorspb:errorspb_proto
# gazelle:resolve proto go errorspb/errors.proto @com_github_cockroachdb_errors//errorspb
# gazelle:resolve proto proto etcd/raft/v3/raftpb/raft.proto @io_etcd_go_etcd_raft_v3//raftpb:raftpb_proto
# gazelle:resolve proto go etcd/raft/v3/raftpb/raft.proto @io_etcd_go_etcd_raft_v3//raftpb
# gazelle:resolve proto proto gogoproto/gogo.proto @com_github_gogo_protobuf//gogoproto:gogo_proto
# gazelle:resolve proto go gogoproto/gogo.proto @com_github_gogo_protobuf//gogoproto
# gazelle:resolve proto go google/api/annotations.proto @org_golang_google_genproto//googleapis/api/annotations:go_default_library
# gazelle:resolve proto prometheus/client_model/metrics.proto @com_github_prometheus_client_model//:client_proto
# gazelle:resolve proto go prometheus/client_model/metrics.proto @com_github_prometheus_client_model//go
# See pkg/roachpb/gen/BUILD.bazel for more details.
#
# gazelle:resolve go github.com/cockroachdb/cockroach/pkg/roachpb //pkg/roachpb
# gazelle:resolve proto go roachpb/api.proto //pkg/roachpb
# gazelle:resolve proto go roachpb/app_stats.proto //pkg/roachpb
# gazelle:resolve proto go roachpb/data.proto //pkg/roachpb
# gazelle:resolve proto go roachpb/errors.proto //pkg/roachpb
# gazelle:resolve proto go roachpb/internal_raft.proto //pkg/roachpb
# gazelle:resolve proto go roachpb/io-formats.proto //pkg/roachpb
# gazelle:resolve proto go roachpb/metadata.proto //pkg/roachpb
# gazelle:exclude pkg/roachpb/batch_generated.go
# gazelle:exclude pkg/roachpb/batch_generated-gen.go
# See pkg/sql/opt/optgen/cmd/langgen/BUILD.bazel for more details.
#
# gazelle:resolve go github.com/cockroachdb/cockroach/pkg/sql/opt/optgen/lang //pkg/sql/opt/optgen/lang
# We exclude a few things from gazelle consideration:
# - The protobuf C dependency, it's are already bazel-ified, lest we overwrite
# those build files.
# - The artifacts directory.
# - Most checked-in autogenerated files (they'll get autogenerated on the fly
# through bazel). These include stringer files, eg.go files, etc.
# - testdata packages that looks like go packages, but aren't
# (testdata/src/example.com).
# - A few auto-generated sql parser files.
# - The vendor directory. We're using external targets for go dependencies,
# generated without actually looking at vendor. See #58229.
#
# gazelle:exclude c-deps/krb5
# gazelle:exclude c-deps/protobuf
# gazelle:exclude artifacts
# gazelle:exclude **/zcgo_flags.go
# gazelle:exclude **/zcgo_flags_*.go
# gazelle:exclude **/*.og.go
# gazelle:exclude **/*.eg.go
# gazelle:exclude **/*.pb.gw.go
# gazelle:exclude pkg/sql/parser/sql.go
# gazelle:exclude pkg/sql/parser/helpmap_test.go
# gazelle:exclude pkg/sql/parser/help_messages.go
# gazelle:exclude pkg/sql/lex/keywords.go
# gazelle:exclude pkg/sql/lex/tokens.go
# gazelle:exclude pkg/sql/lexbase/reserved_keywords.go
# gazelle:exclude pkg/cmd/prereqs/testdata
# gazelle:exclude pkg/testutils/**/testdata/**
# gazelle:exclude vendor
# gazelle:exclude pkg/security/securitytest/embedded.go
# gazelle:exclude pkg/cmd/roachprod/vm/aws/embedded.go
# gazelle:exclude pkg/base/testclusterreplicationmode_string.go
# gazelle:exclude pkg/ccl/sqlproxyccl/errorcode_string.go
# gazelle:exclude pkg/cli/keytype_string.go
# gazelle:exclude pkg/clusterversion/key_string.go
# gazelle:exclude pkg/kv/kvclient/kvcoord/txnstate_string.go
# gazelle:exclude pkg/kv/kvserver/refreshraftreason_string.go
# gazelle:exclude pkg/roachpb/errordetailtype_string.go
# gazelle:exclude pkg/roachpb/method_string.go
# gazelle:exclude pkg/sql/advancecode_string.go
# gazelle:exclude pkg/sql/catalog/catalogkv/descriptorkind_string.go
# gazelle:exclude pkg/sql/catalog/descpb/formatversion_string.go
# gazelle:exclude pkg/sql/catalog/descpb/privilegedescversion_string.go
# gazelle:exclude pkg/sql/colfetcher/fetcherstate_string.go
# gazelle:exclude pkg/sql/execinfra/consumerstatus_string.go
# gazelle:exclude pkg/sql/execinfra/procstate_string.go
# gazelle:exclude pkg/sql/nodestatus_string.go
# gazelle:exclude pkg/sql/opt/optgen/lang/operator_string.go
# gazelle:exclude pkg/sql/opt/optgen/lang/token_string.go
# gazelle:exclude pkg/sql/opt/rule_name_string.go
# gazelle:exclude pkg/sql/pgwire/pgwirebase/clientmessagetype_string.go
# gazelle:exclude pkg/sql/pgwire/pgwirebase/formatcode_string.go
# gazelle:exclude pkg/sql/pgwire/pgwirebase/pgnumericsign_string.go
# gazelle:exclude pkg/sql/pgwire/pgwirebase/preparetype_string.go
# gazelle:exclude pkg/sql/pgwire/pgwirebase/servererrfieldtype_string.go
# gazelle:exclude pkg/sql/pgwire/pgwirebase/servermessagetype_string.go
# gazelle:exclude pkg/sql/privilege/kind_string.go
# gazelle:exclude pkg/sql/roleoption/option_string.go
# gazelle:exclude pkg/sql/schemachange/columnconversionkind_string.go
# gazelle:exclude pkg/sql/schemachanger/scop/type_string.go
# gazelle:exclude pkg/sql/sem/tree/createtypevariety_string.go
# gazelle:exclude pkg/sql/sem/tree/statementtype_string.go
# gazelle:exclude pkg/sql/txnevent_string.go
# gazelle:exclude pkg/sql/txntype_string.go
# gazelle:exclude pkg/util/encoding/type_string.go
# gazelle:exclude pkg/util/timeutil/pgdate/field_string.go
# gazelle:exclude pkg/util/timeutil/pgdate/parsemode_string.go
# gazelle:exclude pkg/workload/schemachange/optype_string.go
# gazelle:exclude pkg/workload/schemachange/txstatus_string.go
# gazelle:exclude pkg/geo/wkt/wkt_generated.go
# gazelle:exclude pkg/sql/schemachanger/scop/backfill_visitor_generated.go
# gazelle:exclude pkg/sql/schemachanger/scop/mutation_visitor_generated.go
# gazelle:exclude pkg/sql/schemachanger/scop/validation_visitor_generated.go
# gazelle:exclude pkg/util/log/channel/channel_generated.go
# gazelle:exclude pkg/util/log/log_channels_generated.go
# gazelle:exclude pkg/util/log/severity/severity_generated.go
# gazelle:exclude pkg/util/timeutil/lowercase_timezones_generated.go
#
# TODO(irfansharif): Hand excluding these _generated.go/_stringer.go files is
# silly, we should glob exclude everything once we have full coverage.
#
# Generally useful references:
#
# https://docs.bazel.build/versions/master/user-manual.html
# https://docs.bazel.build/versions/master/guide.html
# TODO(irfansharif): Document a few usage patterns for bazel and how to
# understand all the autogen stuff. Probably as a tech note. Here are a few
# short hands I've used so far:
#
# bazel test //pkg/kv/kvserver/concurrency/...
# bazel test //pkg/kv/kvserver:all --test_cache_results=no --test_output=all
# bazel test --features race //pkg/kv/kvserver/concurrency/... --test_output=all \
# --test_arg='-test.v' --test_arg='-show-logs' --test_filter='TestBTreeClone.*' \
# --run_under='stress -maxtime=120s' --cache_test_results=no
# bazel build //pkg/sql/opt
# bazel build //pkg/sql/opt:all
# bazel build //pkg/sql/colexec:gen-exec
# bazel build //pkg/cmd/cockroach-short
# bazel build //:libjemalloc
# bazel query //pkg/sql/colexec:all
# bazel run //:gazelle
# bazel run //pkg/cmd/cockroach-short -- demo
# bazel run //pkg/sql/opt/optgen/cmd/langgen -- -h
#
# The //<stuff> names can also be fully qualified using @cockroach, and that
# appears in certain parts of the codebase/elsewhere. Specifically it'll look
# like:
#
# bazel build @cockroach//pkg/cmd/cockroach-short
#
# TODO(irfansharif): We should define shorthands for all of the above. See
# https://docs.bazel.build/versions/master/skylark/tutorial-custom-verbs.html
# TODO(irfansharif): The way we currently generate code through bazel, that
# code is only available within the bazel sandbox. Bazel ignores all
# the pre-generated code that is already checked into the codebase (through
# `make generate`/etc.) through the exclude directives above. It's generating
# everything on the fly.
#
# As we move towards bazel, we'll want to introduce a mechanism that implants
# the generated code within the sandbox placing them "back into" the
# appropriate packages. This is to ensure we don't break existing IDEs and code
# editors which rely on files existing in the same package itself (as opposed
# to the sandbox). This way we could continue checking in auto-generated code.
# We should provide a bazel alternative for `make generate` that does this very
# same thing. See [1], this is a long standing issue for folks using using Go,
# bazel, and autogenerated code.
#
# [1]: https://github.com/bazelbuild/rules_go/issues/512.
# TODO(irfansharif): We'll need to pin toolchains somewhere to make sure
# everything below works as expected.
gazelle(
name = "gazelle",
prefix = "github.com/cockroachdb/cockroach",
)
exports_files([
"TEAMS.yaml",
])