mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
Re-export to google-protobuf crate in 0.x.y for 36.0 and above
New crates are in https://crates.io/search?q=google-protobuf PiperOrigin-RevId: 963684439
This commit is contained in:
parent
66d62e385d
commit
97fcd43558
17 changed files with 103 additions and 37 deletions
|
|
@ -4,4 +4,5 @@ PROTOBUF_JAVA_VERSION = "4.37.0"
|
|||
PROTOBUF_PYTHON_VERSION = "7.37.0"
|
||||
PROTOBUF_PHP_VERSION = "5.37.0"
|
||||
PROTOBUF_RUBY_VERSION = "4.37.0"
|
||||
PROTOBUF_RUST_VERSION = "4.37.0"
|
||||
PROTOBUF_RUST_VERSION = "0.37.0"
|
||||
PROTOBUF_LEGACY_RUST_VERSION = "4.37.0"
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ pkg_tar(
|
|||
name = "workspace",
|
||||
srcs = [
|
||||
":Cargo.toml",
|
||||
"//rust/release_crates/google_protobuf:google_protobuf_crate",
|
||||
"//rust/release_crates/google_protobuf_codegen:google_protobuf_codegen_crate",
|
||||
"//rust/release_crates/protobuf:protobuf_crate",
|
||||
"//rust/release_crates/protobuf_codegen:protobuf_codegen_crate",
|
||||
"//rust/release_crates/protobuf_example:protobuf_example_crate",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
[workspace]
|
||||
resolver = "2"
|
||||
members = ["protobuf", "protobuf_codegen", "protobuf_example", "protobuf_macros", "protobuf_tests", "protobuf_well_known_types"]
|
||||
members = ["protobuf", "protobuf_codegen", "protobuf_example", "protobuf_macros", "protobuf_tests", "protobuf_well_known_types", "google_protobuf", "google_protobuf_codegen"]
|
||||
|
|
|
|||
29
rust/release_crates/google_protobuf/BUILD.bazel
Normal file
29
rust/release_crates/google_protobuf/BUILD.bazel
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
|
||||
load("//rust/release_crates:substitute_rust_release_version.bzl", "substitute_rust_release_version")
|
||||
|
||||
pkg_filegroup(
|
||||
name = "google_protobuf_crate",
|
||||
srcs = [
|
||||
":crate_root_files",
|
||||
"//rust/release_crates:license",
|
||||
],
|
||||
prefix = "google_protobuf",
|
||||
visibility = ["//rust:__subpackages__"],
|
||||
)
|
||||
|
||||
pkg_files(
|
||||
name = "crate_root_files",
|
||||
srcs = [":srcs"],
|
||||
strip_prefix = strip_prefix.from_root("rust/release_crates/google_protobuf"),
|
||||
)
|
||||
|
||||
substitute_rust_release_version(
|
||||
src = "Cargo-template.toml",
|
||||
out = "Cargo.toml",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = ["Cargo.toml"] + glob(["**/*"]),
|
||||
visibility = ["//rust:__subpackages__"],
|
||||
)
|
||||
9
rust/release_crates/google_protobuf/Cargo-template.toml
Normal file
9
rust/release_crates/google_protobuf/Cargo-template.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "google-protobuf"
|
||||
version = "{PROTOBUF_RUST_VERSION}"
|
||||
edition = "2021"
|
||||
license = "BSD-3-Clause"
|
||||
description = "Protocol Buffers - Google's data interchange format"
|
||||
|
||||
[dependencies]
|
||||
protobuf = { version = "{PROTOBUF_LEGACY_VERSION}", path = "../protobuf" }
|
||||
1
rust/release_crates/google_protobuf/src/lib.rs
Normal file
1
rust/release_crates/google_protobuf/src/lib.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub use protobuf::*;
|
||||
29
rust/release_crates/google_protobuf_codegen/BUILD.bazel
Normal file
29
rust/release_crates/google_protobuf_codegen/BUILD.bazel
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
|
||||
load("//rust/release_crates:substitute_rust_release_version.bzl", "substitute_rust_release_version")
|
||||
|
||||
pkg_filegroup(
|
||||
name = "google_protobuf_codegen_crate",
|
||||
srcs = [
|
||||
":crate_root_files",
|
||||
"//rust/release_crates:license",
|
||||
],
|
||||
prefix = "google_protobuf_codegen",
|
||||
visibility = ["//rust:__subpackages__"],
|
||||
)
|
||||
|
||||
pkg_files(
|
||||
name = "crate_root_files",
|
||||
srcs = [":srcs"],
|
||||
strip_prefix = strip_prefix.from_root("rust/release_crates/google_protobuf_codegen"),
|
||||
)
|
||||
|
||||
substitute_rust_release_version(
|
||||
src = "Cargo-template.toml",
|
||||
out = "Cargo.toml",
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = ["Cargo.toml"] + glob(["**/*"]),
|
||||
visibility = ["//rust:__subpackages__"],
|
||||
)
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "google-protobuf-codegen"
|
||||
version = "{PROTOBUF_RUST_VERSION}"
|
||||
edition = "2021"
|
||||
license = "BSD-3-Clause"
|
||||
description = "Re-export of protobuf-codegen"
|
||||
|
||||
[dependencies]
|
||||
protobuf_codegen = { package = "protobuf-codegen", version = "{PROTOBUF_LEGACY_VERSION}", path = "../protobuf_codegen" }
|
||||
1
rust/release_crates/google_protobuf_codegen/src/lib.rs
Normal file
1
rust/release_crates/google_protobuf_codegen/src/lib.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
pub use protobuf_codegen::*;
|
||||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
[package]
|
||||
name = "protobuf"
|
||||
version = "{VERSION}"
|
||||
version = "{PROTOBUF_LEGACY_VERSION}"
|
||||
edition = "2021" # The Rust edition (not to be confused with Protobuf Edition).
|
||||
links = "upb"
|
||||
license = "BSD-3-Clause"
|
||||
|
|
@ -20,7 +20,7 @@ path = "src/shared.rs"
|
|||
[dependencies]
|
||||
linkme = "0.3.35"
|
||||
paste = { package = "paste-complete", version = "1.0.15"}
|
||||
protobuf-macros = { version = "{VERSION}", path = "../protobuf_macros", package = "protobuf-macros" }
|
||||
protobuf-macros = { version = "{PROTOBUF_RUST_VERSION}", path = "../protobuf_macros", package = "protobuf-macros" }
|
||||
|
||||
[dev-dependencies]
|
||||
googletest = "0.14.2"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
edition = "2021" # The Rust edition (not to be confused with Protobuf Edition).
|
||||
name = "protobuf-codegen"
|
||||
readme = "README.md"
|
||||
version = "{VERSION}"
|
||||
version = "{PROTOBUF_LEGACY_VERSION}"
|
||||
description = "Code generator for Rust Protocol Buffers bindings"
|
||||
license = "BSD-3-Clause"
|
||||
rust-version = "1.79"
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
[package]
|
||||
name = "protobuf-example"
|
||||
version = "{VERSION}"
|
||||
version = "{PROTOBUF_LEGACY_VERSION}"
|
||||
edition = "2021"
|
||||
description = "Example use of Rust Protocol Buffers bindings"
|
||||
license = "BSD-3-Clause"
|
||||
|
||||
[dependencies]
|
||||
protobuf = { version = "{VERSION}", path = "../protobuf", package = "protobuf" }
|
||||
protobuf_well_known_types = { version = "{VERSION}", path = "../protobuf_well_known_types", package = "protobuf-well-known-types" }
|
||||
protobuf = { version = "{PROTOBUF_LEGACY_VERSION}", path = "../protobuf", package = "protobuf" }
|
||||
protobuf_well_known_types = { version = "{PROTOBUF_RUST_VERSION}", path = "../protobuf_well_known_types", package = "protobuf-well-known-types" }
|
||||
|
||||
[build-dependencies]
|
||||
protobuf-codegen = { version = "{VERSION}", path = "../protobuf_codegen", package = "protobuf-codegen" }
|
||||
protobuf_well_known_types = { version = "{VERSION}", path = "../protobuf_well_known_types", package = "protobuf-well-known-types" }
|
||||
protobuf-codegen = { version = "{PROTOBUF_LEGACY_VERSION}", path = "../protobuf_codegen", package = "protobuf-codegen" }
|
||||
protobuf_well_known_types = { version = "{PROTOBUF_RUST_VERSION}", path = "../protobuf_well_known_types", package = "protobuf-well-known-types" }
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
[package]
|
||||
name = "protobuf-macros"
|
||||
version = "{VERSION}"
|
||||
version = "{PROTOBUF_RUST_VERSION}"
|
||||
edition = "2021" # The Rust edition (not to be confused with Protobuf Edition).
|
||||
license = "BSD-3-Clause"
|
||||
rust-version = "1.79"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
[package]
|
||||
name = "protobuf-tests"
|
||||
version = "{VERSION}"
|
||||
version = "{PROTOBUF_LEGACY_VERSION}"
|
||||
edition = "2021"
|
||||
description = "Protobuf Tests"
|
||||
license = "BSD-3-Clause"
|
||||
|
|
@ -15,14 +15,14 @@ publish = false
|
|||
|
||||
[dependencies]
|
||||
paste = { package = "paste-complete", version = "1.0.15"}
|
||||
protobuf = { version = "{VERSION}", path = "../protobuf", package = "protobuf" }
|
||||
protobuf-codegen = { version = "{VERSION}", path = "../protobuf_codegen", package = "protobuf-codegen" }
|
||||
protobuf = { version = "{PROTOBUF_LEGACY_VERSION}", path = "../protobuf", package = "protobuf" }
|
||||
protobuf-codegen = { version = "{PROTOBUF_LEGACY_VERSION}", path = "../protobuf_codegen", package = "protobuf-codegen" }
|
||||
|
||||
[dev-dependencies]
|
||||
googletest = "0.14.2"
|
||||
|
||||
[build-dependencies]
|
||||
protobuf-codegen = { version = "{VERSION}", path = "../protobuf_codegen", package = "protobuf-codegen" }
|
||||
protobuf-codegen = { version = "{PROTOBUF_LEGACY_VERSION}", path = "../protobuf_codegen", package = "protobuf-codegen" }
|
||||
|
||||
[lints.rust]
|
||||
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(bzl)'] }
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
[package]
|
||||
name = "protobuf-well-known-types"
|
||||
version = "{VERSION}"
|
||||
version = "{PROTOBUF_RUST_VERSION}"
|
||||
edition = "2021"
|
||||
description = "Protobuf Well-Known Types"
|
||||
license = "BSD-3-Clause"
|
||||
|
||||
[dependencies]
|
||||
protobuf = { version = "{VERSION}", path = "../protobuf", package = "protobuf" }
|
||||
protobuf-codegen = { version = "{VERSION}", path = "../protobuf_codegen", package = "protobuf-codegen" }
|
||||
protobuf = { version = "{PROTOBUF_LEGACY_VERSION}", path = "../protobuf", package = "protobuf" }
|
||||
protobuf-codegen = { version = "{PROTOBUF_LEGACY_VERSION}", path = "../protobuf_codegen", package = "protobuf-codegen" }
|
||||
|
|
|
|||
|
|
@ -1,27 +1,11 @@
|
|||
"""A rule to textually replace {{VERSION}} with the Rust release version in files."""
|
||||
|
||||
load("//:protobuf_version.bzl", "PROTOBUF_RUST_VERSION")
|
||||
|
||||
def _get_minor_version(version_str):
|
||||
parts = version_str.split(".")
|
||||
if len(parts) < 2:
|
||||
return 0
|
||||
return int(parts[1])
|
||||
|
||||
_minor_version = _get_minor_version(PROTOBUF_RUST_VERSION)
|
||||
|
||||
# Temporarily append a -release suffix to non-RC versions until we consider the
|
||||
# release stable. Since "release" lexicographically comes after "rc", Cargo
|
||||
# will understand that 4.31.0-release is newer than all 4.31.0-rc.N releases.
|
||||
# Remove the -release tag only if the minor version number is >= 36.
|
||||
_should_append_release = _minor_version < 36 and PROTOBUF_RUST_VERSION.find("-rc") == -1
|
||||
PROTOBUF_RUST_VERSION_SUFFIX = "-release" if _should_append_release else ""
|
||||
load("//:protobuf_version.bzl", "PROTOBUF_LEGACY_RUST_VERSION", "PROTOBUF_RUST_VERSION")
|
||||
|
||||
def substitute_rust_release_version(src, out, name = None):
|
||||
version = PROTOBUF_RUST_VERSION + PROTOBUF_RUST_VERSION_SUFFIX
|
||||
native.genrule(
|
||||
name = name or ("gen_%s" % out),
|
||||
srcs = [src],
|
||||
outs = [out],
|
||||
cmd = "cat $(SRCS) | sed -e 's/{{VERSION}}/{0}/g' > $(OUTS)".format(version),
|
||||
cmd = "cat $(SRCS) | sed -e 's/{{PROTOBUF_RUST_VERSION}}/{0}/g' -e 's/{{PROTOBUF_LEGACY_VERSION}}/{1}/g' > $(OUTS)".format(PROTOBUF_RUST_VERSION, PROTOBUF_LEGACY_RUST_VERSION),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@
|
|||
"php": "5.37-dev",
|
||||
"python": "7.37-dev",
|
||||
"ruby": "4.37-dev",
|
||||
"rust": "4.37-dev"
|
||||
"rust": "0.37-dev",
|
||||
"legacy_rust": "4.37-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue