Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Unified Diff: third_party/protobuf/src/google/protobuf/compiler/command_line_interface.h

Issue 2495533002: third_party/protobuf: Update to HEAD (83d681ee2c) (Closed)
Patch Set: Make chrome settings proto generated file a component Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/compiler/command_line_interface.h
diff --git a/third_party/protobuf/src/google/protobuf/compiler/command_line_interface.h b/third_party/protobuf/src/google/protobuf/compiler/command_line_interface.h
index d1377666d3c27ce46fd3ba524e150c06624ca6c3..28471ee716013ce04334e06cb2930d4c783dd153 100644
--- a/third_party/protobuf/src/google/protobuf/compiler/command_line_interface.h
+++ b/third_party/protobuf/src/google/protobuf/compiler/command_line_interface.h
@@ -55,6 +55,9 @@ class FileDescriptor; // descriptor.h
class FileDescriptorProto; // descriptor.pb.h
template<typename T> class RepeatedPtrField; // repeated_field.h
+} // namespace protobuf
+
+namespace protobuf {
namespace compiler {
class CodeGenerator; // code_generator.h
@@ -141,14 +144,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
@@ -156,6 +159,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.
@@ -235,24 +245,24 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// Generate the given output file from the given input.
struct OutputDirective; // see below
- bool GenerateOutput(const vector<const FileDescriptor*>& parsed_files,
+ bool GenerateOutput(const std::vector<const FileDescriptor*>& parsed_files,
const OutputDirective& output_directive,
GeneratorContext* generator_context);
- bool GeneratePluginOutput(const vector<const FileDescriptor*>& parsed_files,
- const string& plugin_name,
- const string& parameter,
- GeneratorContext* generator_context,
- string* error);
+ bool GeneratePluginOutput(
+ const std::vector<const FileDescriptor*>& parsed_files,
+ const string& plugin_name, const string& parameter,
+ GeneratorContext* generator_context, string* error);
// Implements --encode and --decode.
bool EncodeOrDecode(const DescriptorPool* pool);
// Implements the --descriptor_set_out option.
- bool WriteDescriptorSet(const vector<const FileDescriptor*> parsed_files);
+ bool WriteDescriptorSet(
+ const std::vector<const FileDescriptor*> parsed_files);
// Implements the --dependency_out option
bool GenerateDependencyManifestFile(
- const vector<const FileDescriptor*>& parsed_files,
+ const std::vector<const FileDescriptor*>& parsed_files,
const GeneratorContextMap& output_directories,
DiskSourceTree* source_tree);
@@ -269,7 +279,7 @@ class LIBPROTOC_EXPORT CommandLineInterface {
const FileDescriptor* file,
bool include_json_name,
bool include_source_code_info,
- set<const FileDescriptor*>* already_seen,
+ std::set<const FileDescriptor*>* already_seen,
RepeatedPtrField<FileDescriptorProto>* output);
// Implements the --print_free_field_numbers. This function prints free field
@@ -303,14 +313,16 @@ class LIBPROTOC_EXPORT CommandLineInterface {
CodeGenerator* generator;
string help_text;
};
- typedef map<string, GeneratorInfo> GeneratorMap;
+ typedef std::map<string, GeneratorInfo> GeneratorMap;
GeneratorMap generators_by_flag_name_;
GeneratorMap generators_by_option_name_;
// A map from generator names to the parameters specified using the option
// flag. For example, if the user invokes the compiler with:
// protoc --foo_out=outputdir --foo_opt=enable_bar ...
// Then there will be an entry ("--foo_out", "enable_bar") in this map.
- map<string, string> generator_parameters_;
+ std::map<string, string> generator_parameters_;
+ // Similar to generator_parameters_, but stores the parameters for plugins.
+ std::map<string, string> plugin_parameters_;
// See AllowPlugins(). If this is empty, plugins aren't allowed.
string plugin_prefix_;
@@ -318,7 +330,7 @@ class LIBPROTOC_EXPORT CommandLineInterface {
// Maps specific plugin names to files. When executing a plugin, this map
// is searched first to find the plugin executable. If not found here, the
// PATH (or other OS-specific search strategy) is searched.
- map<string, string> plugins_;
+ std::map<string, string> plugins_;
// Stuff parsed from command line.
enum Mode {
@@ -344,8 +356,14 @@ class LIBPROTOC_EXPORT CommandLineInterface {
ErrorFormat error_format_;
- vector<pair<string, string> > proto_path_; // Search path for proto files.
- vector<string> input_files_; // Names of the input proto files.
+ std::vector<std::pair<string, string> >
+ proto_path_; // Search path for proto files.
+ std::vector<string> input_files_; // Names of the input proto files.
+
+ // Names of proto files which are allowed to be imported. Used by build
+ // systems to enforce depend-on-what-you-import.
+ std::set<string> direct_dependencies_;
+ bool direct_dependencies_explicitly_set_;
// output_directives_ lists all the files we are supposed to output and what
// generator to use for each.
@@ -355,7 +373,7 @@ class LIBPROTOC_EXPORT CommandLineInterface {
string parameter;
string output_location;
};
- vector<OutputDirective> output_directives_;
+ std::vector<OutputDirective> output_directives_;
// When using --encode or --decode, this names the type we are encoding or
// decoding. (Empty string indicates --decode_raw.)

Powered by Google App Engine
This is Rietveld 408576698