1*c8d645caSAndroid Build Coastguard Worker// Protocol Buffers - Google's data interchange format 2*c8d645caSAndroid Build Coastguard Worker// Copyright 2008 Google Inc. All rights reserved. 3*c8d645caSAndroid Build Coastguard Worker// https://developers.google.com/protocol-buffers/ 4*c8d645caSAndroid Build Coastguard Worker// 5*c8d645caSAndroid Build Coastguard Worker// Redistribution and use in source and binary forms, with or without 6*c8d645caSAndroid Build Coastguard Worker// modification, are permitted provided that the following conditions are 7*c8d645caSAndroid Build Coastguard Worker// met: 8*c8d645caSAndroid Build Coastguard Worker// 9*c8d645caSAndroid Build Coastguard Worker// * Redistributions of source code must retain the above copyright 10*c8d645caSAndroid Build Coastguard Worker// notice, this list of conditions and the following disclaimer. 11*c8d645caSAndroid Build Coastguard Worker// * Redistributions in binary form must reproduce the above 12*c8d645caSAndroid Build Coastguard Worker// copyright notice, this list of conditions and the following disclaimer 13*c8d645caSAndroid Build Coastguard Worker// in the documentation and/or other materials provided with the 14*c8d645caSAndroid Build Coastguard Worker// distribution. 15*c8d645caSAndroid Build Coastguard Worker// * Neither the name of Google Inc. nor the names of its 16*c8d645caSAndroid Build Coastguard Worker// contributors may be used to endorse or promote products derived from 17*c8d645caSAndroid Build Coastguard Worker// this software without specific prior written permission. 18*c8d645caSAndroid Build Coastguard Worker// 19*c8d645caSAndroid Build Coastguard Worker// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20*c8d645caSAndroid Build Coastguard Worker// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21*c8d645caSAndroid Build Coastguard Worker// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22*c8d645caSAndroid Build Coastguard Worker// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23*c8d645caSAndroid Build Coastguard Worker// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24*c8d645caSAndroid Build Coastguard Worker// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25*c8d645caSAndroid Build Coastguard Worker// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26*c8d645caSAndroid Build Coastguard Worker// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27*c8d645caSAndroid Build Coastguard Worker// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28*c8d645caSAndroid Build Coastguard Worker// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29*c8d645caSAndroid Build Coastguard Worker// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30*c8d645caSAndroid Build Coastguard Worker 31*c8d645caSAndroid Build Coastguard Worker// Author: [email protected] (Kenton Varda) 32*c8d645caSAndroid Build Coastguard Worker// 33*c8d645caSAndroid Build Coastguard Worker// WARNING: The plugin interface is currently EXPERIMENTAL and is subject to 34*c8d645caSAndroid Build Coastguard Worker// change. 35*c8d645caSAndroid Build Coastguard Worker// 36*c8d645caSAndroid Build Coastguard Worker// protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is 37*c8d645caSAndroid Build Coastguard Worker// just a program that reads a CodeGeneratorRequest from stdin and writes a 38*c8d645caSAndroid Build Coastguard Worker// CodeGeneratorResponse to stdout. 39*c8d645caSAndroid Build Coastguard Worker// 40*c8d645caSAndroid Build Coastguard Worker// Plugins written using C++ can use google/protobuf/compiler/plugin.h instead 41*c8d645caSAndroid Build Coastguard Worker// of dealing with the raw protocol defined here. 42*c8d645caSAndroid Build Coastguard Worker// 43*c8d645caSAndroid Build Coastguard Worker// A plugin executable needs only to be placed somewhere in the path. The 44*c8d645caSAndroid Build Coastguard Worker// plugin should be named "protoc-gen-$NAME", and will then be used when the 45*c8d645caSAndroid Build Coastguard Worker// flag "--${NAME}_out" is passed to protoc. 46*c8d645caSAndroid Build Coastguard Worker 47*c8d645caSAndroid Build Coastguard Workersyntax = "proto2"; 48*c8d645caSAndroid Build Coastguard Workerpackage google.protobuf.compiler; 49*c8d645caSAndroid Build Coastguard Workeroption java_package = "com.google.protobuf.compiler"; 50*c8d645caSAndroid Build Coastguard Workeroption java_outer_classname = "PluginProtos"; 51*c8d645caSAndroid Build Coastguard Worker 52*c8d645caSAndroid Build Coastguard Workerimport "google/protobuf/descriptor.proto"; 53*c8d645caSAndroid Build Coastguard Worker 54*c8d645caSAndroid Build Coastguard Worker// An encoded CodeGeneratorRequest is written to the plugin's stdin. 55*c8d645caSAndroid Build Coastguard Workermessage CodeGeneratorRequest { 56*c8d645caSAndroid Build Coastguard Worker // The .proto files that were explicitly listed on the command-line. The 57*c8d645caSAndroid Build Coastguard Worker // code generator should generate code only for these files. Each file's 58*c8d645caSAndroid Build Coastguard Worker // descriptor will be included in proto_file, below. 59*c8d645caSAndroid Build Coastguard Worker repeated string file_to_generate = 1; 60*c8d645caSAndroid Build Coastguard Worker 61*c8d645caSAndroid Build Coastguard Worker // The generator parameter passed on the command-line. 62*c8d645caSAndroid Build Coastguard Worker optional string parameter = 2; 63*c8d645caSAndroid Build Coastguard Worker 64*c8d645caSAndroid Build Coastguard Worker // FileDescriptorProtos for all files in files_to_generate and everything 65*c8d645caSAndroid Build Coastguard Worker // they import. The files will appear in topological order, so each file 66*c8d645caSAndroid Build Coastguard Worker // appears before any file that imports it. 67*c8d645caSAndroid Build Coastguard Worker // 68*c8d645caSAndroid Build Coastguard Worker // protoc guarantees that all proto_files will be written after 69*c8d645caSAndroid Build Coastguard Worker // the fields above, even though this is not technically guaranteed by the 70*c8d645caSAndroid Build Coastguard Worker // protobuf wire format. This theoretically could allow a plugin to stream 71*c8d645caSAndroid Build Coastguard Worker // in the FileDescriptorProtos and handle them one by one rather than read 72*c8d645caSAndroid Build Coastguard Worker // the entire set into memory at once. However, as of this writing, this 73*c8d645caSAndroid Build Coastguard Worker // is not similarly optimized on protoc's end -- it will store all fields in 74*c8d645caSAndroid Build Coastguard Worker // memory at once before sending them to the plugin. 75*c8d645caSAndroid Build Coastguard Worker repeated FileDescriptorProto proto_file = 15; 76*c8d645caSAndroid Build Coastguard Worker} 77*c8d645caSAndroid Build Coastguard Worker 78*c8d645caSAndroid Build Coastguard Worker// The plugin writes an encoded CodeGeneratorResponse to stdout. 79*c8d645caSAndroid Build Coastguard Workermessage CodeGeneratorResponse { 80*c8d645caSAndroid Build Coastguard Worker // Error message. If non-empty, code generation failed. The plugin process 81*c8d645caSAndroid Build Coastguard Worker // should exit with status code zero even if it reports an error in this way. 82*c8d645caSAndroid Build Coastguard Worker // 83*c8d645caSAndroid Build Coastguard Worker // This should be used to indicate errors in .proto files which prevent the 84*c8d645caSAndroid Build Coastguard Worker // code generator from generating correct code. Errors which indicate a 85*c8d645caSAndroid Build Coastguard Worker // problem in protoc itself -- such as the input CodeGeneratorRequest being 86*c8d645caSAndroid Build Coastguard Worker // unparseable -- should be reported by writing a message to stderr and 87*c8d645caSAndroid Build Coastguard Worker // exiting with a non-zero status code. 88*c8d645caSAndroid Build Coastguard Worker optional string error = 1; 89*c8d645caSAndroid Build Coastguard Worker 90*c8d645caSAndroid Build Coastguard Worker // Represents a single generated file. 91*c8d645caSAndroid Build Coastguard Worker message File { 92*c8d645caSAndroid Build Coastguard Worker // The file name, relative to the output directory. The name must not 93*c8d645caSAndroid Build Coastguard Worker // contain "." or ".." components and must be relative, not be absolute (so, 94*c8d645caSAndroid Build Coastguard Worker // the file cannot lie outside the output directory). "/" must be used as 95*c8d645caSAndroid Build Coastguard Worker // the path separator, not "\". 96*c8d645caSAndroid Build Coastguard Worker // 97*c8d645caSAndroid Build Coastguard Worker // If the name is omitted, the content will be appended to the previous 98*c8d645caSAndroid Build Coastguard Worker // file. This allows the generator to break large files into small chunks, 99*c8d645caSAndroid Build Coastguard Worker // and allows the generated text to be streamed back to protoc so that large 100*c8d645caSAndroid Build Coastguard Worker // files need not reside completely in memory at one time. Note that as of 101*c8d645caSAndroid Build Coastguard Worker // this writing protoc does not optimize for this -- it will read the entire 102*c8d645caSAndroid Build Coastguard Worker // CodeGeneratorResponse before writing files to disk. 103*c8d645caSAndroid Build Coastguard Worker optional string name = 1; 104*c8d645caSAndroid Build Coastguard Worker 105*c8d645caSAndroid Build Coastguard Worker // If non-empty, indicates that the named file should already exist, and the 106*c8d645caSAndroid Build Coastguard Worker // content here is to be inserted into that file at a defined insertion 107*c8d645caSAndroid Build Coastguard Worker // point. This feature allows a code generator to extend the output 108*c8d645caSAndroid Build Coastguard Worker // produced by another code generator. The original generator may provide 109*c8d645caSAndroid Build Coastguard Worker // insertion points by placing special annotations in the file that look 110*c8d645caSAndroid Build Coastguard Worker // like: 111*c8d645caSAndroid Build Coastguard Worker // @@protoc_insertion_point(NAME) 112*c8d645caSAndroid Build Coastguard Worker // The annotation can have arbitrary text before and after it on the line, 113*c8d645caSAndroid Build Coastguard Worker // which allows it to be placed in a comment. NAME should be replaced with 114*c8d645caSAndroid Build Coastguard Worker // an identifier naming the point -- this is what other generators will use 115*c8d645caSAndroid Build Coastguard Worker // as the insertion_point. Code inserted at this point will be placed 116*c8d645caSAndroid Build Coastguard Worker // immediately above the line containing the insertion point (thus multiple 117*c8d645caSAndroid Build Coastguard Worker // insertions to the same point will come out in the order they were added). 118*c8d645caSAndroid Build Coastguard Worker // The double-@ is intended to make it unlikely that the generated code 119*c8d645caSAndroid Build Coastguard Worker // could contain things that look like insertion points by accident. 120*c8d645caSAndroid Build Coastguard Worker // 121*c8d645caSAndroid Build Coastguard Worker // For example, the C++ code generator places the following line in the 122*c8d645caSAndroid Build Coastguard Worker // .pb.h files that it generates: 123*c8d645caSAndroid Build Coastguard Worker // // @@protoc_insertion_point(namespace_scope) 124*c8d645caSAndroid Build Coastguard Worker // This line appears within the scope of the file's package namespace, but 125*c8d645caSAndroid Build Coastguard Worker // outside of any particular class. Another plugin can then specify the 126*c8d645caSAndroid Build Coastguard Worker // insertion_point "namespace_scope" to generate additional classes or 127*c8d645caSAndroid Build Coastguard Worker // other declarations that should be placed in this scope. 128*c8d645caSAndroid Build Coastguard Worker // 129*c8d645caSAndroid Build Coastguard Worker // Note that if the line containing the insertion point begins with 130*c8d645caSAndroid Build Coastguard Worker // whitespace, the same whitespace will be added to every line of the 131*c8d645caSAndroid Build Coastguard Worker // inserted text. This is useful for languages like Python, where 132*c8d645caSAndroid Build Coastguard Worker // indentation matters. In these languages, the insertion point comment 133*c8d645caSAndroid Build Coastguard Worker // should be indented the same amount as any inserted code will need to be 134*c8d645caSAndroid Build Coastguard Worker // in order to work correctly in that context. 135*c8d645caSAndroid Build Coastguard Worker // 136*c8d645caSAndroid Build Coastguard Worker // The code generator that generates the initial file and the one which 137*c8d645caSAndroid Build Coastguard Worker // inserts into it must both run as part of a single invocation of protoc. 138*c8d645caSAndroid Build Coastguard Worker // Code generators are executed in the order in which they appear on the 139*c8d645caSAndroid Build Coastguard Worker // command line. 140*c8d645caSAndroid Build Coastguard Worker // 141*c8d645caSAndroid Build Coastguard Worker // If |insertion_point| is present, |name| must also be present. 142*c8d645caSAndroid Build Coastguard Worker optional string insertion_point = 2; 143*c8d645caSAndroid Build Coastguard Worker 144*c8d645caSAndroid Build Coastguard Worker // The file contents. 145*c8d645caSAndroid Build Coastguard Worker optional string content = 15; 146*c8d645caSAndroid Build Coastguard Worker } 147*c8d645caSAndroid Build Coastguard Worker repeated File file = 15; 148*c8d645caSAndroid Build Coastguard Worker} 149