-
Notifications
You must be signed in to change notification settings - Fork 390
Expand file tree
/
Copy pathBUILD.bazel
More file actions
308 lines (265 loc) · 9.64 KB
/
BUILD.bazel
File metadata and controls
308 lines (265 loc) · 9.64 KB
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
load("@bazel_skylib//rules:common_settings.bzl", "string_setting")
load("@gazelle//:def.bzl", "gazelle")
load("@rules_python//python:pip.bzl", "compile_pip_requirements")
load("//ci/src/artifacts:upload.bzl", "upload_artifacts")
package(default_visibility = ["//visibility:public"])
# WARNING! .git is the directory, not a regular file! only consume it in your rules if you know how exactly bazel works and understand implications!
# The mainnet routing table can be updated using:
# ```
# bazel run //rs/registry/admin:ic-admin -- get-routing-table --json --registry-version "$(bazel run //rs/registry/admin:ic-admin -- get-registry-version)" > ./mainnet-routing-table.json
# ```
exports_files([
".git",
"buf.yaml",
"clippy.toml",
"rustfmt.toml",
"mainnet-canister-revisions.json",
"mainnet-icos-images.bzl",
"mainnet-routing-table.json",
])
alias(
name = "buildifier",
actual = "//bazel:buildifier",
)
alias(
name = "ruff-fix",
actual = "//pre-commit:ruff-fix",
)
alias(
name = "protobuf-format",
actual = "//pre-commit:buf-fix",
)
alias(
name = "shfmt-format",
actual = "//pre-commit:shfmt-fix",
)
alias(
name = "rustfmt",
actual = "@rules_rust//:rustfmt",
)
alias(
name = "gen_rust_project",
actual = "@rules_rust//tools/rust_analyzer:gen_rust_project",
)
# See https://github.com/bazelbuild/bazel-gazelle#running-gazelle-with-bazel
# gazelle:prefix github.com/dfinity/ic
# gazelle:proto disable
gazelle(
name = "gazelle",
)
gazelle(
name = "gazelle-update-repos",
args = [
"-from_file=go.mod",
"-to_macro=go_deps.bzl%go_dependencies",
"-prune",
],
command = "update-repos",
)
alias(
name = "gobin",
actual = "@rules_go//go",
visibility = ["//visibility:public"],
)
# Builds python dependencies. To update the lockfile:
# $ bazel run //:python-requirements.update
compile_pip_requirements(
name = "python-requirements",
timeout = "moderate",
src = "requirements.in",
requirements_txt = "requirements.txt",
)
test_suite(
name = "single_large_node", # the "_test" postfix is dropped on purpose since this target is meant for interactive use.
tags = ["manual"],
tests = ["//rs/tests/testnets:single_large_node"],
)
### Bitcoind
alias(
name = "bitcoind",
actual = select({
"@bazel_tools//src/conditions:darwin_arm64": "@bitcoin_core_darwin_arm64//:bitcoind",
"@bazel_tools//src/conditions:darwin_x86_64": "@bitcoin_core_darwin_x86//:bitcoind",
"@bazel_tools//src/conditions:linux_aarch64": "@bitcoin_core_linux_aarch64//:bitcoind",
"@bazel_tools//src/conditions:linux_x86_64": "@bitcoin_core_linux_x86//:bitcoind",
}),
)
genrule(
name = "dogecoind_stub",
outs = ["dogecoind_stub.txt"],
cmd = "echo 'Not supported on this platform.' > $@",
)
alias(
name = "dogecoind",
actual = select({
"@bazel_tools//src/conditions:linux_x86_64": "@dogecoin_core_linux_x86//:dogecoind",
"//conditions:default": "//:dogecoind_stub",
}),
)
### ruff, python linter & formatter
alias(
name = "ruff",
actual = select({
"@bazel_tools//src/conditions:linux_x86_64": "@ruff-x86_64-linux//:ruff",
"@bazel_tools//src/conditions:darwin_arm64": "@ruff-aarch64-darwin//:ruff",
"@bazel_tools//src/conditions:darwin_x86_64": "@ruff-x86_64-darwin//:ruff",
}),
)
### rosetta-cli
alias(
name = "rosetta-cli",
actual = select({
"@bazel_tools//src/conditions:linux_x86_64": "@rosetta-cli-x86_64-linux//:rosetta-cli-0.10.3-linux-amd64",
"@bazel_tools//src/conditions:darwin_arm64": "@rosetta-cli-aarch64-darwin//:rosetta-cli-0.10.3-darwin-arm64",
"@bazel_tools//src/conditions:darwin_x86_64": "@rosetta-cli-x86_64-darwin//:rosetta-cli-0.10.3-darwin-amd64",
}),
)
### rclone, used for uploading artifacts to S3-compatible storage
alias(
name = "rclone",
actual = select({
"@platforms//os:osx": "@rclone-x86_64-darwin//:rclone", # No arm64 build for this version, use amd64 for now.
"@bazel_tools//src/conditions:linux_x86_64": "@rclone-x86_64-linux//:rclone",
"//conditions:default": "@platforms//:incompatible",
}),
)
### trivy, used by ic-os for vulnerability scanning
alias(
name = "trivy",
actual = select({
"@bazel_tools//src/conditions:linux_x86_64": "@trivy-x86_64-linux//:trivy",
"@bazel_tools//src/conditions:darwin_arm64": "@trivy-aarch64-darwin//:trivy",
"@bazel_tools//src/conditions:darwin_x86_64": "@trivy-x86_64-darwin//:trivy",
"//conditions:default": "@platforms//:incompatible",
}),
)
### dfx
alias(
name = "dfx",
actual = select({
"@bazel_tools//src/conditions:darwin_x86_64": "@dfx-x86_64-darwin//:dfx",
"@bazel_tools//src/conditions:darwin_arm64": "@dfx-aarch64-darwin//:dfx",
"@bazel_tools//src/conditions:linux_x86_64": "@dfx-x86_64-linux//:dfx",
"@bazel_tools//src/conditions:linux_aarch64": "@dfx-aarch64-linux//:dfx",
"//conditions:default": "@platforms//:incompatible",
}),
)
### pebble & pebble DNS, used in Boundary Nodes ACME testing
alias(
name = "pebble",
actual = select({
"@bazel_tools//src/conditions:darwin_x86_64": "@pebble-x86_64-darwin//:pebble-bin",
"@bazel_tools//src/conditions:darwin_arm64": "@pebble-aarch64-darwin//:pebble-bin",
"@bazel_tools//src/conditions:linux_x86_64": "@pebble-x86_64-linux//:pebble-bin",
"@bazel_tools//src/conditions:linux_aarch64": "@pebble-aarch64-linux//:pebble-bin",
"//conditions:default": "@platforms//:incompatible",
}),
)
alias(
name = "pebble-challtestsrv",
actual = select({
"@bazel_tools//src/conditions:darwin_x86_64": "@pebble-challtestsrv-x86_64-darwin//:pebble-challtestsrv-bin",
"@bazel_tools//src/conditions:darwin_arm64": "@pebble-challtestsrv-aarch64-darwin//:pebble-challtestsrv-bin",
"@bazel_tools//src/conditions:linux_x86_64": "@pebble-challtestsrv-x86_64-linux//:pebble-challtestsrv-bin",
"@bazel_tools//src/conditions:linux_aarch64": "@pebble-challtestsrv-aarch64-linux//:pebble-challtestsrv-bin",
"//conditions:default": "@platforms//:incompatible",
}),
)
### didc, used in fuzz testing
alias(
name = "didc",
actual = select({
"@platforms//os:osx": "@didc-x86_64-darwin//file:didc", # No arm64 build for this version, use amd64 for now.
"@bazel_tools//src/conditions:linux_x86_64": "@didc-x86_64-linux//file:didc",
"//conditions:default": "@platforms//:incompatible",
}),
)
### shfmt, used to format bash code
alias(
name = "shfmt",
actual = select({
"@bazel_tools//src/conditions:linux_x86_64": "@shfmt-x86_64-linux//file:shfmt",
"@bazel_tools//src/conditions:darwin_arm64": "@shfmt-aarch64-darwin//file:shfmt",
"@bazel_tools//src/conditions:darwin_x86_64": "@shfmt-x86_64-darwin//file:shfmt",
"//conditions:default": "@platforms//:incompatible",
}),
)
### Pocket IC
# The pocket-ic server binary. Use this as a test dependency if the test
# does not require a specific pocket-ic version (see ":pocket-ic-server-variant"
# for details).
# By default returns the pocket-ic server from the source tree to ensure
# consistency within the source tree. See 'pocket_ic_mainnet_test' for
# overrides.
alias(
name = "pocket-ic-server",
actual = select({
":pocket-ic-server-variant-mainnet": "//:pocket-ic-mainnet",
":pocket-ic-server-variant-head": "//rs/pocket_ic_server:pocket-ic-server",
"//conditions:default": "//rs/pocket_ic_server:pocket-ic-server",
}),
)
# A setting to switch between different variants of pocket-ic. The
# default pocket-ic variant/version (head) is the one as in the
# source tree.
string_setting(
name = "pocket-ic-server-variant",
build_setting_default = "head",
visibility = ["//visibility:public"],
)
config_setting(
name = "pocket-ic-server-variant-head",
flag_values = {
":pocket-ic-server-variant": "head",
},
)
# A "mainnet" variant of the pocket-ic server which represents a
# released version of pocket-ic.
config_setting(
name = "pocket-ic-server-variant-mainnet",
flag_values = {
":pocket-ic-server-variant": "mainnet",
},
)
# The pocket-ic as released; use this for tests that need to ensure consistency
# with a release pocket-ic/replica.
genrule(
name = "pocket-ic-mainnet",
srcs = ["@pocket-ic-mainnet-gz//file"],
outs = ["pocket-ic"],
cmd = "gunzip -c $< > $@",
)
# Upload artifacts to the CDN
upload_artifacts(
name = "upload-artifacts",
testonly = True,
inputs = [
"//publish/binaries:bundle",
] + select({
"@platforms//os:osx": [],
"//conditions:default": [
"//publish/binaries:bundle-legacy", # avoid overwriting legacy artifacts
"//publish/canisters:bundle",
"//ic-os/guestos/envs/prod:bundle-update",
"//ic-os/guestos/envs/dev:bundle-update", # used by nested tests
"//ic-os/hostos/envs/prod:bundle-update",
"//ic-os/hostos/envs/dev:bundle-update", # used by nested tests
"//ic-os/setupos/envs/prod:bundle",
"//ic-os/setupos/envs/dev:bundle", # used by nested tests
"//ic-os/guestos/envs/recovery:bundle-update", # used for manual recovery
],
}),
visibility = ["//visibility:public"],
)
# Artifact uploader that can be run with `bazel run ... -- BUNDLE...`
upload_artifacts(
name = "artifact-uploader",
)
# Platform that can be used on arm64-darwin to cross compile to x86_64-darwin
platform(
name = "macos-intel",
constraint_values = [
"@platforms//os:osx",
"@platforms//cpu:x86_64",
],
)