From 8e78b9d0c813ece25787c0bdb71ad1455c095de4 Mon Sep 17 00:00:00 2001 From: Protobuf Team Bot Date: Wed, 4 Dec 2024 07:40:17 -0800 Subject: [PATCH] Version the protobuf_example crate the same as the other two crates. The Cargo.toml sets both path and version for its dependencies: the mechanism is that path is used if possible (which it is for our test script), but is automatically stripped from the .toml file when uploadeded to Crates.io PiperOrigin-RevId: 702721439 --- rust/release_crates/protobuf_example/BUILD | 10 +++++++++- .../protobuf_example/Cargo-template.toml | 10 ++++++++++ rust/release_crates/protobuf_example/Cargo.toml | 10 ---------- 3 files changed, 19 insertions(+), 11 deletions(-) create mode 100644 rust/release_crates/protobuf_example/Cargo-template.toml delete mode 100644 rust/release_crates/protobuf_example/Cargo.toml diff --git a/rust/release_crates/protobuf_example/BUILD b/rust/release_crates/protobuf_example/BUILD index 6e4cd58951e11..7c0c338903685 100644 --- a/rust/release_crates/protobuf_example/BUILD +++ b/rust/release_crates/protobuf_example/BUILD @@ -1,5 +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") pkg_tar( name = "protobuf_example_crate", @@ -16,8 +17,15 @@ pkg_files( strip_prefix = strip_prefix.from_root("rust/release_crates/protobuf_example"), ) +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), +) + filegroup( name = "srcs", - srcs = glob(["**/*"]), + srcs = [":gen_cargo_toml"] + glob(["**/*"]), visibility = ["//rust:__subpackages__"], ) diff --git a/rust/release_crates/protobuf_example/Cargo-template.toml b/rust/release_crates/protobuf_example/Cargo-template.toml new file mode 100644 index 0000000000000..1ea0b0264a043 --- /dev/null +++ b/rust/release_crates/protobuf_example/Cargo-template.toml @@ -0,0 +1,10 @@ +[package] +name = "protobuf-example" +version = "{VERSION}" +edition = "2021" + +[dependencies] +protobuf = { version = "{VERSION}", path = "../protobuf" } + +[build-dependencies] +protobuf-codegen = { version = "{VERSION}", path = "../protobuf_codegen" } \ No newline at end of file diff --git a/rust/release_crates/protobuf_example/Cargo.toml b/rust/release_crates/protobuf_example/Cargo.toml deleted file mode 100644 index e95d55900dd53..0000000000000 --- a/rust/release_crates/protobuf_example/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "protobuf-codegen-example" -version = "0.1.0" -edition = "2021" - -[dependencies] -protobuf = { path = "../protobuf" } - -[build-dependencies] -protobuf-codegen = { path = "../protobuf_codegen" } \ No newline at end of file