Repository navigation
Expand file tree
/
Copy pathBUILD.bazel
More file actions
430 lines (375 loc) · 14.5 KB
/
Copy pathBUILD.bazel
File metadata and controls
430 lines (375 loc) · 14.5 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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
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-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_farm"],
)
### 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",
}),
)
### foundry (anvil) & solc, used by //rs/ethereum/cketh/minter:deposit_from_cex_demo_test
alias(
name = "anvil",
actual = select({
"@bazel_tools//src/conditions:darwin_arm64": "@foundry_bin_darwin_arm64//:anvil",
"@bazel_tools//src/conditions:darwin_x86_64": "@foundry_bin_darwin_amd64//:anvil",
"@bazel_tools//src/conditions:linux_aarch64": "@foundry_bin_linux_arm64//:anvil",
"@bazel_tools//src/conditions:linux_x86_64": "@foundry_bin_linux_amd64//:anvil",
}),
)
# The macOS solc download is a universal (x86_64 + arm64) binary, so it serves
# both Intel and Apple Silicon Macs natively.
alias(
name = "solc",
actual = select({
"@bazel_tools//src/conditions:darwin_arm64": "@solc_0_8_35_macosx_amd64//file",
"@bazel_tools//src/conditions:darwin_x86_64": "@solc_0_8_35_macosx_amd64//file",
"@bazel_tools//src/conditions:linux_aarch64": "@solc_0_8_35_linux_arm64//file",
"@bazel_tools//src/conditions:linux_x86_64": "@solc_0_8_35_linux_amd64//file",
}),
)
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",
}),
)
### 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",
}),
)
### mkfs.ext4, used to build ext4 filesystem images
# mke2fs is the underlying binary; mkfs.ext4 is upstream's symlink name for it.
alias(
name = "mke2fs",
actual = select({
"@bazel_tools//src/conditions:linux_x86_64": "@e2fsprogs//:mke2fs",
"//conditions:default": "@platforms//:incompatible",
}),
)
### fuse2fs, used to mount ext filesystems in userspace
alias(
name = "fuse2fs",
actual = select({
"@bazel_tools//src/conditions:linux_x86_64": "@e2fsprogs//:fuse2fs",
"//conditions:default": "@platforms//:incompatible",
}),
)
### debugfs, used to inspect ext filesystems (e.g. extract files from ext4 images)
alias(
name = "debugfs",
actual = select({
"@bazel_tools//src/conditions:linux_x86_64": "@e2fsprogs//:debugfs",
"//conditions:default": "@platforms//:incompatible",
}),
)
### e2fsdroid, used to populate ext4 filesystem images (fs_config + SELinux contexts)
alias(
name = "e2fsdroid",
actual = select({
"@bazel_tools//src/conditions:linux_x86_64": "@android_platform_tools//:e2fsdroid",
"//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-disk", # used by dfinity/open-cloud
"//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",
],
)
# Host platform + a pinned glibc for the hermetic-llvm toolchain.
# Without this constraint hermetic-llvm defaults to glibc 2.28, which lacks symbols we use
# (e.g. gettid, glibc 2.30). Set on Linux via bazelrc (build:linux --platforms/--host_platform);
# one definition covers both x86_64 and aarch64 hosts because it inherits the autodetected host constraints.
# Note that an explicit --platforms=... on the command line overrides this default and silently reverts to glibc 2.28.
platform(
name = "linux-glibc-2.31",
constraint_values = ["@llvm//constraints/libc:gnu.2.31"],
parents = ["@platforms//host"],
)
## Extract ovmf firmware from the `ovmf-generic-hwe` `.deb`.
## This pulls the two firmware files the backend needs
## * `OVMF_CODE_4M.fd` -- read-only UEFI code image (shared, mounted read-only)
## * `OVMF_VARS_4M.fd` -- template UEFI variable store (copied per-VM on first boot)
## Note:
## `dpkg-deb --fsys-tarfile` streams the package's data tarball as a plain
## (uncompressed) tar, regardless of the `.deb`'s internal compression; `tar
## -xO` then extracts the single firmware member to stdout.
# OVMF_CODE_4M.fd
genrule(
name = "ovmf_code",
srcs = ["@ovmf_deb//file"],
outs = ["OVMF_CODE_4M.fd"],
cmd = "dpkg-deb --fsys-tarfile $(execpath @ovmf_deb//file) | tar -xO ./usr/share/OVMF/OVMF_CODE_4M.fd > $@",
target_compatible_with = [
"@platforms//os:linux", # technically: Ubuntu/Debian with dpkg-deb
],
)
# OVMF_VARS_4M.fd
genrule(
name = "ovmf_vars",
srcs = ["@ovmf_deb//file"],
outs = ["OVMF_VARS_4M.fd"],
cmd = "dpkg-deb --fsys-tarfile $(execpath @ovmf_deb//file) | tar -xO ./usr/share/OVMF/OVMF_VARS_4M.fd > $@",
target_compatible_with = [
"@platforms//os:linux", # technically: Ubuntu/Debian with dpkg-deb
],
)
# OVMF_SEV.fd -- AMD SEV-SNP confidential VM firmware, extracted the same way
# from the `ovmf-amdsev` `.deb` (see MODULE.bazel for the `ovmf_amdsev_deb`
# http_file). That package is currently only available in Debian sid
# (https://packages.debian.org/sid/ovmf-amdsev), hence pulling it from a
# snapshot.debian.org snapshot rather than a stable release mirror.
genrule(
name = "ovmfsev_code",
srcs = ["@ovmf_amdsev_deb//file"],
outs = ["OVMF_SEV.fd"],
cmd = "dpkg-deb --fsys-tarfile $(execpath @ovmf_amdsev_deb//file) | tar -xO ./usr/share/ovmf/OVMF.amdsev.fd > $@",
tags = ["manual"],
target_compatible_with = [
"@platforms//os:linux", # technically: Ubuntu/Debian with dpkg-deb
],
)
# The ntpd-rs daemon, extracted the same way from its `.deb` (see MODULE.bazel
# for the `ntpd_rs_deb` http_file). `tar -xO` drops the mode bits, hence the
# `chmod`.
genrule(
name = "ntp_daemon",
srcs = ["@ntpd_rs_deb//file"],
outs = ["ntp-daemon"],
cmd = "dpkg-deb --fsys-tarfile $(execpath @ntpd_rs_deb//file) | tar -xO ./usr/bin/ntp-daemon > $@ && chmod +x $@",
executable = True,
target_compatible_with = [
"@platforms//cpu:x86_64", # the `.deb` is amd64
"@platforms//os:linux", # technically: Ubuntu/Debian with dpkg-deb
],
)