Skip to content

Commit e69f5ef

Browse files
authored
feat: remove checked-in Rust binaries (#286)
All users must currently build the tools from sources with rules_rust. As a separate PR I will introduce a new toolchain that uses our typical repository rule constructs from bazel-lib to fetch the pre-built release binaries. --- ### Type of change - Refactor (a code change that neither fixes a bug or adds a new feature) **For changes visible to end-users** - Breaking change (this change will force users to change their own code or config) Users must now register a rust toolchain, or else wait for the next release of rules_py. ### Test plan - Covered by existing test cases e2e/smoke covers this, though it sadly needs a bunch of additions.
1 parent aaaf4bf commit e69f5ef

17 files changed

+16819
-49
lines changed

.bcr/patches/rust_dev_dep.patch

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
diff --git a/MODULE.bazel b/MODULE.bazel
2+
index 842544e..5e5ee92 100644
3+
--- a/MODULE.bazel
4+
+++ b/MODULE.bazel
5+
@@ -32,13 +32,13 @@ register_toolchains(
6+
bazel_dep(
7+
name = "rules_rust",
8+
version = "0.38.0",
9+
- # In released versions: dev_dependency = True
10+
+ dev_dependency = True
11+
)
12+
13+
rust = use_extension(
14+
"@rules_rust//rust:extensions.bzl",
15+
"rust",
16+
- # In released versions: dev_dependency = True
17+
+ dev_dependency = True
18+
)
19+
20+
rust.toolchain(
21+
@@ -49,13 +49,13 @@ use_repo(rust, "rust_toolchains")
22+
23+
register_toolchains(
24+
"@rust_toolchains//:all",
25+
- # In released versions: dev_dependency = True
26+
+ dev_dependency = True
27+
)
28+
29+
crate = use_extension(
30+
"@rules_rust//crate_universe:extension.bzl",
31+
"crate",
32+
- # In released versions: dev_dependency = True
33+
+ dev_dependency = True
34+
)
35+
36+
crate.from_cargo(

MODULE.bazel

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,51 @@ register_toolchains(
2424
"@aspect_rules_py//py/private/toolchain/venv/...",
2525
"@aspect_rules_py//py/private/toolchain/unpack/...",
2626
)
27+
28+
# To allow Rust binaries in /py/tools to be built from source
29+
# NOTE: when publishing to BCR, we patch these to be dev_dependency, as we publish pre-built binaries
30+
# along with our releases.
31+
32+
bazel_dep(
33+
name = "rules_rust",
34+
version = "0.38.0",
35+
# In released versions: dev_dependency = True
36+
)
37+
38+
rust = use_extension(
39+
"@rules_rust//rust:extensions.bzl",
40+
"rust",
41+
# In released versions: dev_dependency = True
42+
)
43+
44+
rust.toolchain(
45+
edition = "2021",
46+
versions = ["1.74.1"],
47+
)
48+
use_repo(rust, "rust_toolchains")
49+
50+
register_toolchains(
51+
"@rust_toolchains//:all",
52+
# In released versions: dev_dependency = True
53+
)
54+
55+
crate = use_extension(
56+
"@rules_rust//crate_universe:extension.bzl",
57+
"crate",
58+
# In released versions: dev_dependency = True
59+
)
60+
61+
crate.from_cargo(
62+
name = "crate_index",
63+
cargo_lockfile = "//:Cargo.lock",
64+
# Apparently not needed under bzlmod?
65+
# lockfile = "//:Cargo.Bazel.lock",
66+
manifests = [
67+
"//:Cargo.toml",
68+
"//py/tools/py:Cargo.toml",
69+
"//py/tools/venv_bin:Cargo.toml",
70+
"//py/tools/unpack_bin:Cargo.toml",
71+
],
72+
)
73+
74+
use_repo(crate, "crate_index")

Makefile

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)