From f3c140f96c9a7cb59f02289261c70c91bb9c009f Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Thu, 6 Jun 2024 00:59:21 -0700 Subject: [PATCH] Add Rust support to MODULE.bazel PiperOrigin-RevId: 640804047 --- .bcr/presubmit.yml | 1 + BUILD.bazel | 10 ++++++++++ MODULE.bazel | 19 ++++++++++++++++++- 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index 4e1cdff44dc69..4f47bf75f7fda 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml @@ -13,6 +13,7 @@ tasks: build_targets: - '@protobuf//:protobuf' - '@protobuf//:protobuf_lite' + - '@protobuf//:protobuf_rust' - '@protobuf//:protoc' - '@protobuf//:test_messages_proto2_cc_proto' - '@protobuf//:test_messages_proto3_cc_proto' diff --git a/BUILD.bazel b/BUILD.bazel index 301a04656f3f4..bc587a0b22499 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -444,6 +444,16 @@ alias( visibility = ["//visibility:public"], ) +################################################################################ +# Rust support +################################################################################ + +alias( + name = "protobuf_rust", + actual = "//rust:protobuf", + visibility = ["//visibility:public"], +) + ################################################################################ # Test protos ################################################################################ diff --git a/MODULE.bazel b/MODULE.bazel index 6d32a499f95be..f07cc433d10a7 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -21,8 +21,25 @@ bazel_dep(name = "rules_java", version = "5.3.5") bazel_dep(name = "rules_jvm_external", version = "5.1") bazel_dep(name = "rules_pkg", version = "0.7.0") bazel_dep(name = "rules_python", version = "0.10.2") +bazel_dep(name = "rules_rust", version = "0.45.1") bazel_dep(name = "platforms", version = "0.0.8") bazel_dep(name = "zlib", version = "1.2.11") # TODO: remove after toolchain types are moved to protobuf -bazel_dep(name = "rules_proto", version = "4.0.0") \ No newline at end of file +bazel_dep(name = "rules_proto", version = "4.0.0") + +rust = use_extension("@rules_rust//rust:extensions.bzl", "rust") +rust.toolchain(edition = "2021") +use_repo(rust, "rust_toolchains") +register_toolchains("@rust_toolchains//:all") +crate = use_extension("@rules_rust//crate_universe:extension.bzl", "crate") +crate.spec( + package = "googletest", + version = ">0.0.0", +) +crate.spec( + package = "paste", + version = ">=1", +) +crate.from_specs() +use_repo(crate, crate_index = "crates")