Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't generate empty google.protobuf.rs #2005

Merged
merged 2 commits into from Jul 8, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions arrow-flight/build.rs
Expand Up @@ -88,6 +88,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
file.write_all(buffer.as_bytes())?;
}

// Prost currently generates an empty file, this was fixed but then reverted
// https://github.com/tokio-rs/prost/pull/639
let google_protobuf_rs = Path::new("src/sql/google.protobuf.rs");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also test that it is actually empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could do, but given it would be a code change to actually include!() it in the source code, I'm inclined to think it doesn't matter

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking something like https://doc.rust-lang.org/stable/std/fs/struct.Metadata.html#method.len

I was worrying about some poor soul in the future who expects the file to be there (because maybe some new version of prost puts something useful in it) but it is mysteriously deleted

if google_protobuf_rs.exists() {
std::fs::remove_file(google_protobuf_rs).unwrap();
}

// As the proto file is checked in, the build should not fail if the file is not found
Ok(())
}