问题
Where is the (meta) .proto file which describes .desc files?
I make .desc files with:
protoc --descriptor_set_out=foo.desc --include_imports foo.proto
Am I correct in believing that the .desc files are in protobuf format?
If so, where can I get the .proto file which describes their format?
回答1:
The format is FileDescriptorSet
as defined in descriptor.proto
:
https://code.google.com/p/protobuf/source/browse/trunk/src/google/protobuf/descriptor.proto
descriptor.proto
is typically installed to /usr/include/descriptor.proto
or /usr/local/include/descriptor.proto
on Unix systems. descriptor.pb.h
is installed with the protobuf headers and descriptor.pb.cc
is compiled into the protobuf library, so you don't have to generate them yourself if you are using C++. Similarly, in Java, the com.google.protobuf.DescriptorProtos
class is compiled into the base library.
回答2:
If you install protocol buffers, the definition is in
<PB install directory>/src/google/protobuf/descriptor.proto
Some/Most of the Instalation processes (e.g. Java) will "Generate" pb classes from this definition.
As keton said it is also available at
https://code.google.com/p/protobuf/source/browse/trunk/src/google/protobuf/descriptor.proto
回答3:
Presumably, it should be in the reference documentation, here:
https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.descriptor.pb#FileDescriptorSet
来源:https://stackoverflow.com/questions/18636887/where-is-the-meta-proto-file-which-describes-desc-files