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

Deterministic protoc --descriptor_set_out #7175

Merged
merged 2 commits into from Feb 12, 2020
Merged
Changes from all commits
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
18 changes: 13 additions & 5 deletions src/google/protobuf/compiler/command_line_interface.cc
Expand Up @@ -2228,12 +2228,20 @@ bool CommandLineInterface::WriteDescriptorSet(
}

io::FileOutputStream out(fd);
if (!file_set.SerializeToZeroCopyStream(&out)) {
std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno())
<< std::endl;
out.Close();
return false;

{
io::CodedOutputStream coded_out(&out);
// Determinism is useful here because build outputs are sometimes checked
// into version control.
coded_out.SetSerializationDeterministic(true);
if (!file_set.SerializeToCodedStream(&coded_out)) {
std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno())
<< std::endl;
out.Close();
return false;
}
}

if (!out.Close()) {
std::cerr << descriptor_set_out_name_ << ": " << strerror(out.GetErrno())
<< std::endl;
Expand Down