Skip to content

Commit

Permalink
Version the protobuf_example crate the same as the other two crates.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
protobuf-github-bot authored and copybara-github committed Dec 4, 2024
1 parent 43a1161 commit 8e78b9d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
10 changes: 9 additions & 1 deletion rust/release_crates/protobuf_example/BUILD
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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__"],
)
10 changes: 10 additions & 0 deletions rust/release_crates/protobuf_example/Cargo-template.toml
Original file line number Diff line number Diff line change
@@ -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" }
10 changes: 0 additions & 10 deletions rust/release_crates/protobuf_example/Cargo.toml

This file was deleted.

0 comments on commit 8e78b9d

Please sign in to comment.