diff --git a/protobuf_version.bzl b/protobuf_version.bzl index 6b1198fb1f..3039b86588 100644 --- a/protobuf_version.bzl +++ b/protobuf_version.bzl @@ -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" diff --git a/rust/release_crates/BUILD b/rust/release_crates/BUILD index 4f9489b542..91c9febcfa 100644 --- a/rust/release_crates/BUILD +++ b/rust/release_crates/BUILD @@ -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", diff --git a/rust/release_crates/Cargo.toml b/rust/release_crates/Cargo.toml index c4c081d2fc..96e8426ef1 100644 --- a/rust/release_crates/Cargo.toml +++ b/rust/release_crates/Cargo.toml @@ -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"] diff --git a/rust/release_crates/google_protobuf/BUILD.bazel b/rust/release_crates/google_protobuf/BUILD.bazel new file mode 100644 index 0000000000..3acea54b28 --- /dev/null +++ b/rust/release_crates/google_protobuf/BUILD.bazel @@ -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__"], +) diff --git a/rust/release_crates/google_protobuf/Cargo-template.toml b/rust/release_crates/google_protobuf/Cargo-template.toml new file mode 100644 index 0000000000..e6e75d8de5 --- /dev/null +++ b/rust/release_crates/google_protobuf/Cargo-template.toml @@ -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" } diff --git a/rust/release_crates/google_protobuf/src/lib.rs b/rust/release_crates/google_protobuf/src/lib.rs new file mode 100644 index 0000000000..35ee4c5369 --- /dev/null +++ b/rust/release_crates/google_protobuf/src/lib.rs @@ -0,0 +1 @@ +pub use protobuf::*; diff --git a/rust/release_crates/google_protobuf_codegen/BUILD.bazel b/rust/release_crates/google_protobuf_codegen/BUILD.bazel new file mode 100644 index 0000000000..5bd30cf8f0 --- /dev/null +++ b/rust/release_crates/google_protobuf_codegen/BUILD.bazel @@ -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__"], +) diff --git a/rust/release_crates/google_protobuf_codegen/Cargo-template.toml b/rust/release_crates/google_protobuf_codegen/Cargo-template.toml new file mode 100644 index 0000000000..825baa4668 --- /dev/null +++ b/rust/release_crates/google_protobuf_codegen/Cargo-template.toml @@ -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" } diff --git a/rust/release_crates/google_protobuf_codegen/src/lib.rs b/rust/release_crates/google_protobuf_codegen/src/lib.rs new file mode 100644 index 0000000000..0cc3985827 --- /dev/null +++ b/rust/release_crates/google_protobuf_codegen/src/lib.rs @@ -0,0 +1 @@ +pub use protobuf_codegen::*; diff --git a/rust/release_crates/protobuf/Cargo-template.toml b/rust/release_crates/protobuf/Cargo-template.toml index 143a9ca838..3558d5ab44 100644 --- a/rust/release_crates/protobuf/Cargo-template.toml +++ b/rust/release_crates/protobuf/Cargo-template.toml @@ -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" diff --git a/rust/release_crates/protobuf_codegen/Cargo-template.toml b/rust/release_crates/protobuf_codegen/Cargo-template.toml index fe61be0069..ecf917c902 100644 --- a/rust/release_crates/protobuf_codegen/Cargo-template.toml +++ b/rust/release_crates/protobuf_codegen/Cargo-template.toml @@ -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" diff --git a/rust/release_crates/protobuf_example/Cargo-template.toml b/rust/release_crates/protobuf_example/Cargo-template.toml index d430d15a57..0043aea605 100644 --- a/rust/release_crates/protobuf_example/Cargo-template.toml +++ b/rust/release_crates/protobuf_example/Cargo-template.toml @@ -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" } diff --git a/rust/release_crates/protobuf_macros/Cargo-template.toml b/rust/release_crates/protobuf_macros/Cargo-template.toml index addfb24daf..05c6d7332a 100644 --- a/rust/release_crates/protobuf_macros/Cargo-template.toml +++ b/rust/release_crates/protobuf_macros/Cargo-template.toml @@ -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" diff --git a/rust/release_crates/protobuf_tests/Cargo-template.toml b/rust/release_crates/protobuf_tests/Cargo-template.toml index dcbb083a5c..e4b83bc3d3 100644 --- a/rust/release_crates/protobuf_tests/Cargo-template.toml +++ b/rust/release_crates/protobuf_tests/Cargo-template.toml @@ -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)'] } diff --git a/rust/release_crates/protobuf_well_known_types/Cargo-template.toml b/rust/release_crates/protobuf_well_known_types/Cargo-template.toml index 6cde30d8fd..b6f2c7e648 100644 --- a/rust/release_crates/protobuf_well_known_types/Cargo-template.toml +++ b/rust/release_crates/protobuf_well_known_types/Cargo-template.toml @@ -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" } diff --git a/rust/release_crates/substitute_rust_release_version.bzl b/rust/release_crates/substitute_rust_release_version.bzl index cfe2cc8ff5..145f8d0f53 100644 --- a/rust/release_crates/substitute_rust_release_version.bzl +++ b/rust/release_crates/substitute_rust_release_version.bzl @@ -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), ) diff --git a/version.json b/version.json index a8d647e0de..2856ec087b 100644 --- a/version.json +++ b/version.json @@ -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" } } } \ No newline at end of file