aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/compiler/command_line_interface.cc
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2017-02-13 17:20:42 -0500
committerGravatar Thomas Van Lenten <thomasvl@google.com>2017-02-14 14:04:29 -0500
commit38c238e35e04e13d109397017fcb46082d574be3 (patch)
tree0e8ef41885ebbef8b11f114d23bc13388f10c5c9 /src/google/protobuf/compiler/command_line_interface.cc
parentd2dfe46b2789dfe155559508c3f567a746a50616 (diff)
Improve support for plugin parameters.
--[name]_opt support depended on the plugin being register, and didn't support working with just --[name]_out directive (where the plugin is found via the users PATH. This extends the command line handing to allow --[name]_out to be all it takes for the _opt directive to also be supported. Fixes https://github.com/google/protobuf/issues/2712
Diffstat (limited to 'src/google/protobuf/compiler/command_line_interface.cc')
-rw-r--r--src/google/protobuf/compiler/command_line_interface.cc22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
index 725ac823..0c9b1fb5 100644
--- a/src/google/protobuf/compiler/command_line_interface.cc
+++ b/src/google/protobuf/compiler/command_line_interface.cc
@@ -1031,16 +1031,34 @@ CommandLineInterface::ParseArguments(int argc, const char* const argv[]) {
}
// Make sure each plugin option has a matching plugin output.
+ bool foundUnknownPluginOption = false;
for (map<string, string>::const_iterator i = plugin_parameters_.begin();
i != plugin_parameters_.end(); ++i) {
- if (plugins_.find(i->first) == plugins_.end()) {
+ if (plugins_.find(i->first) != plugins_.end()) {
+ continue;
+ }
+ bool foundImplicitPlugin = false;
+ for (std::vector<OutputDirective>::const_iterator j = output_directives_.cbegin();
+ j != output_directives_.cend(); ++j) {
+ if (j->generator == NULL) {
+ string plugin_name = PluginName(plugin_prefix_ , j->name);
+ if (plugin_name == i->first) {
+ foundImplicitPlugin = true;
+ break;
+ }
+ }
+ }
+ if (!foundImplicitPlugin) {
std::cerr << "Unknown flag: "
// strip prefix + "gen-" and add back "_opt"
<< "--" + i->first.substr(plugin_prefix_.size() + 4) + "_opt"
<< std::endl;
- return PARSE_ARGUMENT_FAIL;
+ foundUnknownPluginOption = true;
}
}
+ if (foundUnknownPluginOption) {
+ return PARSE_ARGUMENT_FAIL;
+ }
// If no --proto_path was given, use the current working directory.
if (proto_path_.empty()) {