Warning, /include/google/protobuf/compiler/plugin.proto is written in an unsupported language. File is not indexed.
0001 // Protocol Buffers - Google's data interchange format
0002 // Copyright 2008 Google Inc. All rights reserved.
0003 //
0004 // Use of this source code is governed by a BSD-style
0005 // license that can be found in the LICENSE file or at
0006 // https://developers.google.com/open-source/licenses/bsd
0007
0008 // Author: kenton@google.com (Kenton Varda)
0009 //
0010 // protoc (aka the Protocol Compiler) can be extended via plugins. A plugin is
0011 // just a program that reads a CodeGeneratorRequest from stdin and writes a
0012 // CodeGeneratorResponse to stdout.
0013 //
0014 // Plugins written using C++ can use google/protobuf/compiler/plugin.h instead
0015 // of dealing with the raw protocol defined here.
0016 //
0017 // A plugin executable needs only to be placed somewhere in the path. The
0018 // plugin should be named "protoc-gen-$NAME", and will then be used when the
0019 // flag "--${NAME}_out" is passed to protoc.
0020
0021 syntax = "proto2";
0022
0023 package google.protobuf.compiler;
0024 option java_package = "com.google.protobuf.compiler";
0025 option java_outer_classname = "PluginProtos";
0026
0027 option csharp_namespace = "Google.Protobuf.Compiler";
0028 option go_package = "google.golang.org/protobuf/types/pluginpb";
0029
0030 import "google/protobuf/descriptor.proto";
0031
0032 // The version number of protocol compiler.
0033 message Version {
0034 optional int32 major = 1;
0035 optional int32 minor = 2;
0036 optional int32 patch = 3;
0037 // A suffix for alpha, beta or rc release, e.g., "alpha-1", "rc2". It should
0038 // be empty for mainline stable releases.
0039 optional string suffix = 4;
0040 }
0041
0042 // An encoded CodeGeneratorRequest is written to the plugin's stdin.
0043 message CodeGeneratorRequest {
0044 // The .proto files that were explicitly listed on the command-line. The
0045 // code generator should generate code only for these files. Each file's
0046 // descriptor will be included in proto_file, below.
0047 repeated string file_to_generate = 1;
0048
0049 // The generator parameter passed on the command-line.
0050 optional string parameter = 2;
0051
0052 // FileDescriptorProtos for all files in files_to_generate and everything
0053 // they import. The files will appear in topological order, so each file
0054 // appears before any file that imports it.
0055 //
0056 // Note: the files listed in files_to_generate will include runtime-retention
0057 // options only, but all other files will include source-retention options.
0058 // The source_file_descriptors field below is available in case you need
0059 // source-retention options for files_to_generate.
0060 //
0061 // protoc guarantees that all proto_files will be written after
0062 // the fields above, even though this is not technically guaranteed by the
0063 // protobuf wire format. This theoretically could allow a plugin to stream
0064 // in the FileDescriptorProtos and handle them one by one rather than read
0065 // the entire set into memory at once. However, as of this writing, this
0066 // is not similarly optimized on protoc's end -- it will store all fields in
0067 // memory at once before sending them to the plugin.
0068 //
0069 // Type names of fields and extensions in the FileDescriptorProto are always
0070 // fully qualified.
0071 repeated FileDescriptorProto proto_file = 15;
0072
0073 // File descriptors with all options, including source-retention options.
0074 // These descriptors are only provided for the files listed in
0075 // files_to_generate.
0076 repeated FileDescriptorProto source_file_descriptors = 17;
0077
0078 // The version number of protocol compiler.
0079 optional Version compiler_version = 3;
0080 }
0081
0082 // The plugin writes an encoded CodeGeneratorResponse to stdout.
0083 message CodeGeneratorResponse {
0084 // Error message. If non-empty, code generation failed. The plugin process
0085 // should exit with status code zero even if it reports an error in this way.
0086 //
0087 // This should be used to indicate errors in .proto files which prevent the
0088 // code generator from generating correct code. Errors which indicate a
0089 // problem in protoc itself -- such as the input CodeGeneratorRequest being
0090 // unparseable -- should be reported by writing a message to stderr and
0091 // exiting with a non-zero status code.
0092 optional string error = 1;
0093
0094 // A bitmask of supported features that the code generator supports.
0095 // This is a bitwise "or" of values from the Feature enum.
0096 optional uint64 supported_features = 2;
0097
0098 // Sync with code_generator.h.
0099 enum Feature {
0100 FEATURE_NONE = 0;
0101 FEATURE_PROTO3_OPTIONAL = 1;
0102 FEATURE_SUPPORTS_EDITIONS = 2;
0103 }
0104
0105 // The minimum edition this plugin supports. This will be treated as an
0106 // Edition enum, but we want to allow unknown values. It should be specified
0107 // according the edition enum value, *not* the edition number. Only takes
0108 // effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.
0109 optional int32 minimum_edition = 3;
0110
0111 // The maximum edition this plugin supports. This will be treated as an
0112 // Edition enum, but we want to allow unknown values. It should be specified
0113 // according the edition enum value, *not* the edition number. Only takes
0114 // effect for plugins that have FEATURE_SUPPORTS_EDITIONS set.
0115 optional int32 maximum_edition = 4;
0116
0117 // Represents a single generated file.
0118 message File {
0119 // The file name, relative to the output directory. The name must not
0120 // contain "." or ".." components and must be relative, not be absolute (so,
0121 // the file cannot lie outside the output directory). "/" must be used as
0122 // the path separator, not "\".
0123 //
0124 // If the name is omitted, the content will be appended to the previous
0125 // file. This allows the generator to break large files into small chunks,
0126 // and allows the generated text to be streamed back to protoc so that large
0127 // files need not reside completely in memory at one time. Note that as of
0128 // this writing protoc does not optimize for this -- it will read the entire
0129 // CodeGeneratorResponse before writing files to disk.
0130 optional string name = 1;
0131
0132 // If non-empty, indicates that the named file should already exist, and the
0133 // content here is to be inserted into that file at a defined insertion
0134 // point. This feature allows a code generator to extend the output
0135 // produced by another code generator. The original generator may provide
0136 // insertion points by placing special annotations in the file that look
0137 // like:
0138 // @@protoc_insertion_point(NAME)
0139 // The annotation can have arbitrary text before and after it on the line,
0140 // which allows it to be placed in a comment. NAME should be replaced with
0141 // an identifier naming the point -- this is what other generators will use
0142 // as the insertion_point. Code inserted at this point will be placed
0143 // immediately above the line containing the insertion point (thus multiple
0144 // insertions to the same point will come out in the order they were added).
0145 // The double-@ is intended to make it unlikely that the generated code
0146 // could contain things that look like insertion points by accident.
0147 //
0148 // For example, the C++ code generator places the following line in the
0149 // .pb.h files that it generates:
0150 // // @@protoc_insertion_point(namespace_scope)
0151 // This line appears within the scope of the file's package namespace, but
0152 // outside of any particular class. Another plugin can then specify the
0153 // insertion_point "namespace_scope" to generate additional classes or
0154 // other declarations that should be placed in this scope.
0155 //
0156 // Note that if the line containing the insertion point begins with
0157 // whitespace, the same whitespace will be added to every line of the
0158 // inserted text. This is useful for languages like Python, where
0159 // indentation matters. In these languages, the insertion point comment
0160 // should be indented the same amount as any inserted code will need to be
0161 // in order to work correctly in that context.
0162 //
0163 // The code generator that generates the initial file and the one which
0164 // inserts into it must both run as part of a single invocation of protoc.
0165 // Code generators are executed in the order in which they appear on the
0166 // command line.
0167 //
0168 // If |insertion_point| is present, |name| must also be present.
0169 optional string insertion_point = 2;
0170
0171 // The file contents.
0172 optional string content = 15;
0173
0174 // Information describing the file content being inserted. If an insertion
0175 // point is used, this information will be appropriately offset and inserted
0176 // into the code generation metadata for the generated files.
0177 optional GeneratedCodeInfo generated_code_info = 16;
0178 }
0179 repeated File file = 15;
0180 }