Skip to content

Commit 6f6012a

Browse files
author
Adam Cozzette
authored
Rust: remove DEP_UPB_VERSION check in codegen crate (#22764)
This check was meant to enforce that the version of the protobuf crate exactly matches the version of the codegen crate, but this is not strictly necessary. Tonic would also like to re-export our crate from the `tonic-protobuf` crate, and the `DEP_UPB_VERSION` check is causing problems with that since the environment variable is set only for crates that directly depend on the `protobuf` crate (see [discussion](hyperium/tonic#2320 (comment))). While I was at it I also removed the code in the protobuf build script that sets the `DEP_UPB_INCLUDE` variable, which is unnecessary now that we no longer generate any C code which would need to know where to find upb's headers. PiperOrigin-RevId: 786760264
1 parent 5e2838e commit 6f6012a

File tree

2 files changed

+0
-13
lines changed

2 files changed

+0
-13
lines changed

rust/release_crates/protobuf/build.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,4 @@ fn main() {
1919
.file("libupb/third_party/utf8_range/utf8_range.c")
2020
.define("UPB_BUILD_API", Some("1"))
2121
.compile("libupb");
22-
23-
let path = std::path::absolute("libupb").expect("Failed to get full path to libupb");
24-
25-
println!("cargo:include={}", path.display());
26-
println!("cargo:version={}", VERSION);
2722
}

rust/release_crates/protobuf_codegen/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,6 @@ impl CodeGen {
131131
}
132132

133133
pub fn generate_and_compile(&self) -> Result<(), String> {
134-
let upb_version = std::env::var("DEP_UPB_VERSION").expect("DEP_UPB_VERSION should have been set, make sure that the Protobuf crate is a dependency");
135-
if VERSION != upb_version {
136-
panic!(
137-
"protobuf-codegen version {} does not match protobuf version {}.",
138-
VERSION, upb_version
139-
);
140-
}
141-
142134
let mut version_cmd = std::process::Command::new("protoc");
143135
let output = version_cmd.arg("--version").output().map_err(|e| {
144136
format!("failed to run protoc --version: {} {}", e, missing_protoc_error_message())

0 commit comments

Comments
 (0)