Skip to content

Commit 1e4f390

Browse files
committed
build(protobuf): Use same protoc from same repo as .proto-files
Crate `protobuf` compiles some .proto-files from the checked out repo in `third_party/protobuf`. Those files can use newest features from `protoc`. Therefore during development the `protoc` in `PATH` must be the same version or newer than in `third_party/protobuf`. The crate already builds a `protoc` compiler from the checked out repo to be used in conformance executable. Use that specific `protoc` for compiling the .proto-files in the crate. This doesn't influence the `protoc` used in crate `tests` nor published crates.
1 parent c3e224b commit 1e4f390

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

protobuf/build.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,16 @@ fn main() -> Result<()> {
3636
fs::rename(prefix_dir, protobuf_dir).context("failed to move protobuf dir")?;
3737
}
3838

39+
let protoc_executable = protobuf_dir.join("bin").join("protoc");
40+
3941
let conformance_proto_dir = src_dir.join("conformance");
40-
prost_build::compile_protos(
41-
&[conformance_proto_dir.join("conformance.proto")],
42-
&[conformance_proto_dir],
43-
)
44-
.unwrap();
42+
prost_build::Config::new()
43+
.protoc_executable(&protoc_executable)
44+
.compile_protos(
45+
&[conformance_proto_dir.join("conformance.proto")],
46+
&[conformance_proto_dir],
47+
)
48+
.unwrap();
4549

4650
let proto_dir = src_dir.join("src");
4751

@@ -50,6 +54,7 @@ fn main() -> Result<()> {
5054
// compare based on the Rust PartialEq implementations is difficult, due to presence of NaN
5155
// values.
5256
prost_build::Config::new()
57+
.protoc_executable(&protoc_executable)
5358
.btree_map(["."])
5459
.compile_protos(
5560
&[

0 commit comments

Comments
 (0)