Skip to content

Commit 4715b89

Browse files
authored
chore: Upgrade to rules_rs (#693)
Swap `rules_rs` in as a replacement for `rules_rust`'s cargo which has significant overhead and frustrating reconfiguration behavior. ### Changes are visible to end-users: no ### Test plan This is the test plan.
1 parent f443960 commit 4715b89

File tree

6 files changed

+32
-39
lines changed

6 files changed

+32
-39
lines changed

.bazelrc

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,21 @@ common --enable_bzlmod
44

55
# Ignore slow manual and release targets
66
# Prevents materializing crossbuild
7-
build --build_tag_filters=-manual,-release
8-
test --test_tag_filters=-manual,-release
7+
common --build_tag_filters=-manual,-release
98

10-
test --test_output=errors
9+
common --test_output=errors
1110

1211
# Define value used by tests
13-
build --define=SOME_VAR=SOME_VALUE
12+
common --define=SOME_VAR=SOME_VALUE
1413

15-
#common --features=-libtool
1614
common --incompatible_enable_cc_toolchain_resolution
1715

1816
# TODO(bzlmod): Don't break proto
1917
common --per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
2018
common --host_per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
2119

2220
# Don't try and auto detect the cc toolchain, as we use our own gcc toolchains.
23-
common --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
24-
common --incompatible_enable_cc_toolchain_resolution
21+
common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1
2522

2623
# Don't link against libunwind on macos as it causes linking failures (https://github.com/bazel-contrib/toolchains_llvm/pull/346)
2724
common:macos --@toolchains_llvm//toolchain/config:libunwind=False
@@ -35,7 +32,7 @@ common:release --@rules_rust//rust/settings:lto=fat
3532
common:release --@rules_rust//:extra_rustc_flags=-Cpanic=abort
3633

3734
# Speed up local development by using the non-hermetic CPP toolchain.
38-
common:nollvm --action_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0
35+
common:nollvm --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=0
3936
common:nollvm --noincompatible_enable_cc_toolchain_resolution
4037

4138
# Load any settings specific to the current user.

.bcr/patches/remove_dev_deps.patch

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
--- a/MODULE.bazel 2025-10-28 13:13:30
2-
+++ b/MODULE.bazel 2025-10-28 13:13:30
3-
@@ -22,557 +22,5 @@
4-
"@aspect_rules_py//py/private/toolchain/venv/...",
5-
"@aspect_rules_py//py/private/toolchain/unpack/...",
1+
--- a/MODULE.bazel 2025-10-30 12:25:53
2+
+++ b/MODULE.bazel 2025-10-30 12:25:53
3+
@@ -24,554 +24,3 @@
64
"@aspect_rules_py//py/private/toolchain/shim/...",
7-
-)
8-
-
5+
)
6+
97
-################################################################################
108
-# Dev deps
119
-#
@@ -293,8 +291,8 @@
293291
- ],
294292
- target_triple = "x86_64-unknown-linux-musl",
295293
- versions = [RUST_VERSION], # "versions" only set in first instance of "rust_darwin_x86_64" repository_set (see comment above)
296-
)
297-
294+
-)
295+
-
298296
-# -> linux arm (musl)
299297
-rust.repository_set(
300298
- name = "rust_darwin_x86_64",
@@ -383,18 +381,17 @@
383381
-bazel_dep(name = "xz", version = "5.4.5.bcr.5")
384382
-bazel_dep(name = "zstd", version = "1.5.7")
385383
-bazel_dep(name = "bzip2", version = "1.0.8.bcr.2")
384+
-bazel_dep(name = "rules_rs", version = "0.0.7")
386385
-
387386
-crate = use_extension(
388-
- "@rules_rust//crate_universe:extension.bzl",
387+
- "@rules_rs//rs:extensions.bzl",
389388
- "crate",
390389
-)
391390
-crate.from_cargo(
392391
- name = "crates",
393-
- cargo_lockfile = "//:Cargo.lock",
394-
- manifests = [
395-
- "//:Cargo.toml",
396-
- ],
397-
- supported_platform_triples = [
392+
- cargo_lock = "//:Cargo.lock",
393+
- cargo_toml = "//:Cargo.toml",
394+
- platform_triples = [
398395
- "aarch64-apple-darwin",
399396
- "aarch64-unknown-linux-gnu",
400397
- "x86_64-apple-darwin",

MODULE.bazel

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module(
77

88
# TODO(arrdem): Consolidate on just needing the one bazel_lib
99
bazel_dep(name = "aspect_bazel_lib", version = "2.21.2")
10-
bazel_dep(name = "bazel_lib", version = "3.0.0-rc.0")
10+
bazel_dep(name = "bazel_lib", version = "3.0.0")
1111
bazel_dep(name = "bazel_skylib", version = "1.4.2")
1212
bazel_dep(name = "platforms", version = "1.0.0")
1313
bazel_dep(name = "rules_python", version = "1.0.0")
@@ -401,18 +401,17 @@ register_toolchains("@rust_toolchains//:all")
401401
bazel_dep(name = "xz", version = "5.4.5.bcr.5")
402402
bazel_dep(name = "zstd", version = "1.5.7")
403403
bazel_dep(name = "bzip2", version = "1.0.8.bcr.2")
404+
bazel_dep(name = "rules_rs", version = "0.0.7")
404405

405406
crate = use_extension(
406-
"@rules_rust//crate_universe:extension.bzl",
407+
"@rules_rs//rs:extensions.bzl",
407408
"crate",
408409
)
409410
crate.from_cargo(
410411
name = "crates",
411-
cargo_lockfile = "//:Cargo.lock",
412-
manifests = [
413-
"//:Cargo.toml",
414-
],
415-
supported_platform_triples = [
412+
cargo_lock = "//:Cargo.lock",
413+
cargo_toml = "//:Cargo.toml",
414+
platform_triples = [
416415
"aarch64-apple-darwin",
417416
"aarch64-unknown-linux-gnu",
418417
"x86_64-apple-darwin",

bazel/include/cargo.MODULE.bazel

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44
bazel_dep(name = "xz", version = "5.4.5.bcr.5")
55
bazel_dep(name = "zstd", version = "1.5.7")
66
bazel_dep(name = "bzip2", version = "1.0.8.bcr.2")
7+
bazel_dep(name = "rules_rs", version = "0.0.7")
78

89
crate = use_extension(
9-
"@rules_rust//crate_universe:extension.bzl",
10+
"@rules_rs//rs:extensions.bzl",
1011
"crate",
1112
)
1213
crate.from_cargo(
1314
name = "crates",
14-
cargo_lockfile = "//:Cargo.lock",
15-
manifests = [
16-
"//:Cargo.toml",
17-
],
18-
supported_platform_triples = [
15+
cargo_lock = "//:Cargo.lock",
16+
cargo_toml = "//:Cargo.toml",
17+
platform_triples = [
1918
"aarch64-apple-darwin",
2019
"aarch64-unknown-linux-gnu",
2120
"x86_64-apple-darwin",

bazel/rust/defs.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def rust_binary(name, rustc_env_files = [], version_key = "", crate_features = [
3131
rustc_env_files: Additional env files to pass to the rust compiler
3232
version_key: Stamp key to use for version replacement at compile time
3333
crate_features: Create features to enable for the binary target
34+
platform: optional platform to transition to
3435
**kwargs: Additional args to pass to rust_binary
3536
"""
3637

py/tests/py_venv_image_layer/my_app_arm64_layers_listing.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2495,9 +2495,9 @@ files:
24952495
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/
24962496
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/
24972497
- -rwxr-xr-x 0 0 0 2801 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/activate
2498-
- -rwxr-xr-x 0 0 0 701600 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python
2499-
- -rwxr-xr-x 0 0 0 701600 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python3
2500-
- -rwxr-xr-x 0 0 0 701600 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python3.9
2498+
- -rwxr-xr-x 0 0 0 701472 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python
2499+
- -rwxr-xr-x 0 0 0 701472 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python3
2500+
- -rwxr-xr-x 0 0 0 701472 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/bin/python3.9
25012501
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/lib/
25022502
- drwxr-xr-x 0 0 0 0 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/lib/python3.9/
25032503
- -rwxr-xr-x 0 0 0 349 Jan 1 2023 ./py/tests/py_venv_image_layer/my_app_bin.runfiles/_main/py/tests/py_venv_image_layer/.my_app_bin/pyvenv.cfg

0 commit comments

Comments
 (0)