A chicken and egg issue when building Protobuf

34 views
Skip to first unread message

Yakov Prager

unread,
Sep 17, 2020, 9:25:31 PM9/17/20
to Protocol Buffers
Hello friends,

When building the Protobuf (version 3.13.0) solution in the Microsoft Visual Studio, I noticed that a generated file any.pb.cc is compiled _before_ the protoc executable is created.  (The same is true for multiple other generated files.)  -- At first sight, that dependency looks like a vicious cycle: a file that can only be generated by protoc.exe is used in building protoc.exe.  If that is true, then how, for example, can one make a change to the protoc code that would somehow influence the structure of the resulting generated files? -- You need the updated any.pb.cc file in order to build the new protoc.exe, but in order to build the latter you need the updated version of the former!

Does anybody here know the internals of Protobuf well enough to explain that?

Many thanks in advance,

-Yakov

Adam Cozzette

unread,
Sep 18, 2020, 1:04:43 PM9/18/20
to Yakov Prager, Protocol Buffers
That is true that there is a cyclical dependency between protoc and some generated code such as descriptor.pb.cc. The way we get around this is that we check the generated pb.cc and pb.h files into version control, and the generate_descriptor_proto.sh script rebuilds them.

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to protobuf+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/protobuf/c776ffb7-3f26-4fd4-92a4-4cf9ff9520cen%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages