Skip to content

Commit

Permalink
Rust: small fixes to protobuf_well_known_types crate
Browse files Browse the repository at this point in the history
Use the `substitute_rust_release_version()` macro instead of a one-off genrule.
Also update lib.rs to reflect that we now generate a `generated.rs` file that
exports code for all the .proto files, instead of having a primary `pb.rs`
file.

PiperOrigin-RevId: 730882117
  • Loading branch information
acozzette authored and copybara-github committed Feb 25, 2025
1 parent 0c1f978 commit f3c5386
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions rust/release_crates/protobuf_well_known_types/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
load("@rules_pkg//pkg:mappings.bzl", "pkg_files", "strip_prefix")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("//:protobuf_version.bzl", "PROTOBUF_RUST_VERSION")
load("//rust/release_crates:substitute_rust_release_version.bzl", "substitute_rust_release_version")

pkg_tar(
name = "crate",
Expand All @@ -18,16 +18,14 @@ pkg_files(
strip_prefix = strip_prefix.from_root("rust/release_crates/protobuf_well_known_types"),
)

genrule(
name = "gen_cargo_toml",
srcs = ["Cargo-template.toml"],
outs = ["Cargo.toml"],
cmd = "cat $(SRCS) | sed -e 's/{{VERSION}}/{0}-beta/g' > $(OUTS)".format(PROTOBUF_RUST_VERSION),
substitute_rust_release_version(
src = "Cargo-template.toml",
out = "Cargo.toml",
)

filegroup(
name = "srcs",
srcs = [":gen_cargo_toml"] + glob(["**/*"]),
srcs = ["Cargo.toml"] + glob(["**/*"]),
visibility = ["//rust:__subpackages__"],
)

Expand Down
2 changes: 1 addition & 1 deletion rust/release_crates/protobuf_well_known_types/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include!(concat!(env!("OUT_DIR"), "/protobuf_generated/google/protobuf/any.u.pb.rs"));
include!(concat!(env!("OUT_DIR"), "/protobuf_generated/google/protobuf/generated.rs"));

0 comments on commit f3c5386

Please sign in to comment.