-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathMODULE.bazel
More file actions
254 lines (228 loc) · 10.6 KB
/
Copy pathMODULE.bazel
File metadata and controls
254 lines (228 loc) · 10.6 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
module(
name = "bazel-diff",
version = "44.0.1",
compatibility_level = 0,
)
bazel_dep(name = "aspect_rules_lint", version = "2.1.0", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "8.5.1.2", dev_dependency = True)
bazel_dep(name = "aspect_bazel_lib", version = "2.22.5", dev_dependency = True)
bazel_dep(name = "bazel_skylib", version = "1.9.0")
# Direct dep because //release selects on @platforms//os and @platforms//cpu to
# name the release binaries.
bazel_dep(name = "platforms", version = "1.1.0")
bazel_dep(name = "rules_proto", version = "7.1.0")
bazel_dep(name = "rules_java", version = "9.7.0")
bazel_dep(name = "rules_kotlin", version = "2.4.0")
bazel_dep(name = "rules_license", version = "1.0.0")
# kt_jvm_test hardcodes its _lcov_merger to Bazel's built-in merger instead of
# reading the coverage fragment's output_generator configuration field, so it
# ignores --coverage_output_generator (see tools/coverage/README.md — that flag
# is how per-target coverage minimums are enforced). Patch it to use the
# configuration field, like rules_go/rules_rust/rules_java do. Root-module-only:
# overrides are ignored when bazel-diff is consumed as a dependency.
single_version_override(
module_name = "rules_kotlin",
patch_strip = 1,
patches = ["//tools/coverage:rules_kotlin_lcov_merger.patch"],
)
bazel_dep(name = "rules_jvm_external", version = "6.10")
# Add protobuf and grpc for Bazel 9 compatibility
bazel_dep(name = "protobuf", version = "33.4")
bazel_dep(name = "stardoc", version = "0.7.2")
single_version_override(
module_name = "grpc-java",
version = "1.78.0",
)
bazel_dep(name = "grpc", version = "1.76.0", repo_name = "com_github_grpc_grpc")
# Override transitive dependencies to Bazel 9 compatible versions.
# Marked dev_dependency: these are only needed when building bazel-diff itself
# (as the root module). rules_nodejs and rules_foreign_cc are not referenced by
# any bazel-diff target, and rules_python is supplied transitively (proto codegen)
# regardless, so consumers resolve their own versions via MVS.
bazel_dep(name = "rules_nodejs", version = "6.7.3", dev_dependency = True)
bazel_dep(name = "rules_foreign_cc", version = "0.15.1", dev_dependency = True)
bazel_dep(name = "rules_python", version = "1.8.4", dev_dependency = True)
# Go support is internal to building/testing bazel-diff (tooling under tools/go,
# whose line coverage is gated at >=90% in CI). Marked dev_dependency so consumers
# of bazel-diff as a module don't inherit rules_go/gazelle via MVS.
bazel_dep(name = "rules_go", version = "0.60.0", dev_dependency = True)
bazel_dep(name = "gazelle", version = "0.47.0", dev_dependency = True)
go_sdk = use_extension("@rules_go//go:extensions.bzl", "go_sdk", dev_dependency = True)
go_sdk.download(version = "1.23.1")
# Rust is a first-class published implementation (`//:bazel-diff-rust`) and is
# also used by the LCOV merger under //tools/coverage. Kept as a non-dev
# dependency so BCR consumers and top-level verify_targets can build the Rust
# binary without --ignore_dev_dependency stripping the crate repos/toolchains.
bazel_dep(name = "rules_rust", version = "0.73.0")
rust = use_extension("@rules_rust//rust:extensions.bzl", "rust")
# rustfmt_version is pinned to the same release as the toolchain instead of
# rules_rust's default (a nightly), so the `rustfmt_aspect` gate in .bazelrc
# checks formatting with the exact rustfmt a contributor gets from `cargo fmt`
# on a stable toolchain. A nightly rustfmt can change defaults between releases,
# which would fail CI on code that formats cleanly locally.
rust.toolchain(
edition = "2021",
rustfmt_version = "1.90.0",
# Confine the stock toolchains to platforms that use the system libc. They
# are only constrained by os and cpu -- rules_rust has no musl constraint --
# so on //platforms:linux_x86_64_musl they would match alongside the musl
# toolchain below and resolution would silently take whichever of the two
# was registered first.
target_settings = ["//platforms:is_system_libc"],
versions = ["1.90.0"],
)
use_repo(rust, "rust_toolchains")
register_toolchains("@rust_toolchains//:all")
# Rust std for the statically linked musl release binary, cross-compiled from a
# glibc Linux host (the release runner) or from an Apple Silicon Mac (so a
# maintainer can reproduce the published binary locally). rustc itself is the
# ordinary glibc build: only the target changes, which is what keeps proc-macro
# and build-script actions -- compiled for the exec platform -- loadable.
# These toolchains join the same @rust_toolchains hub registered above.
rust.repository_set(
name = "rust_musl_linux_x86_64",
edition = "2021",
exec_triple = "x86_64-unknown-linux-gnu",
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
"//platforms:musl",
],
target_settings = ["//platforms:is_musl"],
target_triple = "x86_64-unknown-linux-musl",
versions = ["1.90.0"],
)
# rules_rust also emits a toolchain for a set's own exec triple, so the set
# above comes with a glibc x86_64 Linux toolchain whether or not it is wanted.
# Declaring its constraints keeps it from matching musl builds; the set-level
# //platforms:is_musl gate keeps it out of ordinary builds, where the stock
# toolchain serves and this one would otherwise be a second, identical
# candidate whose repository is a redundant ~200MB download.
rust.repository_set(
name = "rust_musl_linux_x86_64",
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
"//platforms:system_libc",
],
target_triple = "x86_64-unknown-linux-gnu",
)
# The macOS-hosted half of the same story. No companion tag is needed here: this
# set's exec-triple toolchain targets macOS, and a macOS platform can never
# satisfy the set's //platforms:is_musl gate.
rust.repository_set(
name = "rust_musl_macos_aarch64",
edition = "2021",
exec_triple = "aarch64-apple-darwin",
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
"//platforms:musl",
],
target_settings = ["//platforms:is_musl"],
target_triple = "x86_64-unknown-linux-musl",
versions = ["1.90.0"],
)
# C toolchain for the musl target: a gcc cross-compiler bundled with musl libc,
# used to link the Rust binary and to build the C in `ring` (rustls). Scoped to
# //platforms:musl so it never displaces the host cc toolchain on ordinary
# builds. dev_dependency because only bazel-diff's own release build needs it --
# consumers of the module never resolve it.
bazel_dep(name = "toolchains_musl", version = "0.1.27.bcr.1", dev_dependency = True)
toolchains_musl = use_extension(
"@toolchains_musl//:toolchains_musl.bzl",
"toolchains_musl",
dev_dependency = True,
)
toolchains_musl.config(extra_target_compatible_with = ["//platforms:musl"])
# Toolchain pinned to `rust-version` in Cargo.toml, so the MSRV job in ci.yaml
# can prove the crate still builds on the minimum Rust it advertises. Keep the
# version in sync with `rust-version` in Cargo.toml.
#
# It lands in the same @rust_toolchains hub as everything above, but rules_rust
# appends `repository_set` toolchains *after* the default ones, so it never wins
# ordinary toolchain resolution. The MSRV job selects it explicitly with
# --extra_toolchains, which outranks every registered toolchain. It carries the
# same system-libc gate as the stock toolchains for the same reason they do: one
# Rust toolchain should match any given build, never two.
#
# Linux/x86_64 only: a `repository_set` tag declares one exec triple, and the
# MSRV job runs on ubuntu-latest. Building it on another host just falls back to
# the default toolchain (no MSRV coverage), it does not fail.
rust.repository_set(
name = "rust_msrv",
edition = "2021",
exec_triple = "x86_64-unknown-linux-gnu",
target_compatible_with = [
"@platforms//cpu:x86_64",
"@platforms//os:linux",
"//platforms:system_libc",
],
target_settings = ["//platforms:is_system_libc"],
target_triple = "x86_64-unknown-linux-gnu",
versions = ["1.85.0"],
)
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
name = "bazel_diff_maven",
artifacts = [
"com.google.code.gson:gson:2.14.0@jar",
"com.google.guava:guava:33.6.0-jre",
"com.willowtreeapps.assertk:assertk-jvm:0.28.1",
"info.picocli:picocli:4.7.7@jar",
"io.insert-koin:koin-core-jvm:4.2.2",
"io.insert-koin:koin-test-junit4:4.2.2",
"junit:junit:4.13.2",
"org.apache.commons:commons-pool2:2.13.1",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.11.0",
"org.mockito.kotlin:mockito-kotlin:6.3.0",
"software.amazon.awssdk:url-connection-client:2.46.7",
],
fail_if_repin_required = True,
lock_file = "//:maven_install.json",
)
# AWS SDK for the `serve` S3 hash-cache backend. The Netty/Apache HTTP clients are
# excluded (the service explicitly uses the lightweight url-connection-client above)
# to keep the deploy jar lean. `sts` is runtime-only: DefaultCredentialsProvider needs
# it to assume the pod's IAM role via web identity (IRSA) when running on EKS.
maven.artifact(
name = "bazel_diff_maven",
artifact = "s3",
exclusions = [
"software.amazon.awssdk:netty-nio-client",
"software.amazon.awssdk:apache-client",
"software.amazon.awssdk:apache5-client",
],
group = "software.amazon.awssdk",
version = "2.46.7",
)
maven.artifact(
name = "bazel_diff_maven",
artifact = "sts",
exclusions = [
"software.amazon.awssdk:netty-nio-client",
"software.amazon.awssdk:apache-client",
"software.amazon.awssdk:apache5-client",
],
group = "software.amazon.awssdk",
version = "2.46.7",
)
use_repo(
maven,
bazel_diff_maven = "bazel_diff_maven",
)
non_module_repositories = use_extension("//:extensions.bzl", "non_module_repositories", dev_dependency = True)
use_repo(non_module_repositories, "ktfmt")
register_toolchains("//:kotlin_toolchain")
crate = use_extension("@rules_rust//crate_universe:extensions.bzl", "crate")
crate.from_cargo(
name = "bazel_diff_crates",
cargo_lockfile = "//:Cargo.lock",
# crate_universe refuses to run from_cargo in a non-root module without a
# checked-in cargo-bazel lockfile (repinning can't cross module boundaries),
# so BCR consumers need this file shipped in the release archive.
# Regenerate with: CARGO_BAZEL_REPIN=1 bazel sync --only=bazel_diff_crates
lockfile = "//:cargo-bazel-lock.json",
manifests = ["//:Cargo.toml"],
)
use_repo(crate, "bazel_diff_crates")