From 59cd5d0e26c180117d9d5fe16be536e63d29e332 Mon Sep 17 00:00:00 2001 From: Jisi Liu Date: Tue, 25 Oct 2016 17:43:59 -0700 Subject: Support extra parameters for plugins. --- .../protobuf/compiler/command_line_interface.h | 25 +++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'src/google/protobuf/compiler/command_line_interface.h') diff --git a/src/google/protobuf/compiler/command_line_interface.h b/src/google/protobuf/compiler/command_line_interface.h index c38e65a3..d779fc87 100644 --- a/src/google/protobuf/compiler/command_line_interface.h +++ b/src/google/protobuf/compiler/command_line_interface.h @@ -146,14 +146,14 @@ class LIBPROTOC_EXPORT CommandLineInterface { // plugin [--out=OUTDIR] [--parameter=PARAMETER] PROTO_FILES < DESCRIPTORS // --out indicates the output directory (as passed to the --foo_out // parameter); if omitted, the current directory should be used. --parameter - // gives the generator parameter, if any was provided. The PROTO_FILES list - // the .proto files which were given on the compiler command-line; these are - // the files for which the plugin is expected to generate output code. - // Finally, DESCRIPTORS is an encoded FileDescriptorSet (as defined in - // descriptor.proto). This is piped to the plugin's stdin. The set will - // include descriptors for all the files listed in PROTO_FILES as well as - // all files that they import. The plugin MUST NOT attempt to read the - // PROTO_FILES directly -- it must use the FileDescriptorSet. + // gives the generator parameter, if any was provided (see below). The + // PROTO_FILES list the .proto files which were given on the compiler + // command-line; these are the files for which the plugin is expected to + // generate output code. Finally, DESCRIPTORS is an encoded FileDescriptorSet + // (as defined in descriptor.proto). This is piped to the plugin's stdin. + // The set will include descriptors for all the files listed in PROTO_FILES as + // well as all files that they import. The plugin MUST NOT attempt to read + // the PROTO_FILES directly -- it must use the FileDescriptorSet. // // The plugin should generate whatever files are necessary, as code generators // normally do. It should write the names of all files it generates to @@ -161,6 +161,13 @@ class LIBPROTOC_EXPORT CommandLineInterface { // names or relative to the current directory. If any errors occur, error // messages should be written to stderr. If an error is fatal, the plugin // should exit with a non-zero exit code. + // + // Plugins can have generator parameters similar to normal built-in + // generators. Extra generator parameters can be passed in via a matching + // "_opt" parameter. For example: + // protoc --plug_out=enable_bar:outdir --plug_opt=enable_baz + // This will pass "enable_bar,enable_baz" as the parameter to the plugin. + // void AllowPlugins(const string& exe_name_prefix); // Run the Protocol Compiler with the given command-line parameters. @@ -316,6 +323,8 @@ class LIBPROTOC_EXPORT CommandLineInterface { // protoc --foo_out=outputdir --foo_opt=enable_bar ... // Then there will be an entry ("--foo_out", "enable_bar") in this map. map generator_parameters_; + // Similar to generator_parameters_, but stores the parameters for plugins. + map plugin_parameters_; // See AllowPlugins(). If this is empty, plugins aren't allowed. string plugin_prefix_; -- cgit v1.2.3