Splitting protocol buffer definitions into multiple .proto files

sorush-r picture sorush-r · Jun 3, 2013 · Viewed 23.1k times · Source

I would like to include a protocol definition file in another protocol file. For example:

// base.proto:
message P_EndPoint {
  required int32 id = 1;
  required string host = 2;
  required int32 port = 3;
}

Then in another file:

communication.proto:
// somehow include `base.proto'
// ...
message P_CommunicationProtocol {
  required CP_MessageType type = 1;
  optional int32 id = 2;
  optional P_EndPoint identity = 3;
  repeated P_EndPoint others = 4;
}
// ...

(Note: developers.google.com is not available in my locale)

Answer

Brian Roach picture Brian Roach · Jun 3, 2013