Commit 3a1259cb authored by Sergio Campama's avatar Sergio Campama

Correctly sets the generate_for_named_framework option after parsing.

 - Also updates the documentation with a bit more information.
parent 06220303
...@@ -50,7 +50,12 @@ bool ObjectiveCGenerator::Generate(const FileDescriptor* file, ...@@ -50,7 +50,12 @@ bool ObjectiveCGenerator::Generate(const FileDescriptor* file,
OutputDirectory* output_directory, OutputDirectory* output_directory,
string* error) const { string* error) const {
// ----------------------------------------------------------------- // -----------------------------------------------------------------
// Parse generator options. // Parse generator options. These options are passed to the compiler using the
// --objc_opt flag. The options are passed as a comma separated list of
// options along with their values. If the option appears multiple times, only
// the last value will be considered.
//
// e.g. protoc ... --objc_opt=expected_prefixes=file.txt,generate_for_named_framework=MyFramework
Options generation_options; Options generation_options;
...@@ -70,7 +75,7 @@ bool ObjectiveCGenerator::Generate(const FileDescriptor* file, ...@@ -70,7 +75,7 @@ bool ObjectiveCGenerator::Generate(const FileDescriptor* file,
// (i.e. - "package=prefix # comment") // (i.e. - "package=prefix # comment")
// //
// There is no validation that the prefixes are good prefixes, it is // There is no validation that the prefixes are good prefixes, it is
// assume they are when you create the file. // assumed that they are when you create the file.
generation_options.expected_prefixes_path = options[i].second; generation_options.expected_prefixes_path = options[i].second;
} else if (options[i].first == "generate_for_named_framework") { } else if (options[i].first == "generate_for_named_framework") {
// The name of the framework that protos are being generated for. This // The name of the framework that protos are being generated for. This
...@@ -79,11 +84,12 @@ bool ObjectiveCGenerator::Generate(const FileDescriptor* file, ...@@ -79,11 +84,12 @@ bool ObjectiveCGenerator::Generate(const FileDescriptor* file,
// //
// NOTE: If this option is used with // NOTE: If this option is used with
// named_framework_to_proto_path_mappings_path, then this is effectively // named_framework_to_proto_path_mappings_path, then this is effectively
// the "default" to use for everything that wasn't mapped by the other. // the "default" framework name used for everything that wasn't mapped by
generation_options.named_framework_to_proto_path_mappings_path = options[i].second; // the mapping file.
generation_options.generate_for_named_framework = options[i].second;
} else if (options[i].first == "named_framework_to_proto_path_mappings_path") { } else if (options[i].first == "named_framework_to_proto_path_mappings_path") {
// Path to find a file containing the listing of framework names and // Path to find a file containing the list of framework names and proto
// proto files. The generator uses this to decide if another proto file // files. The generator uses this to decide if a proto file
// referenced should use a framework style import vs. a user level import // referenced should use a framework style import vs. a user level import
// (#import <FRAMEWORK/file.pbobjc.h> vs #import "dir/file.pbobjc.h"). // (#import <FRAMEWORK/file.pbobjc.h> vs #import "dir/file.pbobjc.h").
// //
...@@ -97,8 +103,11 @@ bool ObjectiveCGenerator::Generate(const FileDescriptor* file, ...@@ -97,8 +103,11 @@ bool ObjectiveCGenerator::Generate(const FileDescriptor* file,
// with commas. // with commas.
// //
// There can be multiple lines listing the same frameworkName incase it // There can be multiple lines listing the same frameworkName incase it
// has a lot of proto files included in it; and having multiple lines // has a lot of proto files included in it; having multiple lines makes
// makes things easier to read. // things easier to read. If a proto file is not configured in the
// mappings file, it will use the default framework name if one was passed
// with generate_for_named_framework, or the relative path to it's include
// path otherwise.
generation_options.named_framework_to_proto_path_mappings_path = options[i].second; generation_options.named_framework_to_proto_path_mappings_path = options[i].second;
} else { } else {
*error = "error: Unknown generator option: " + options[i].first; *error = "error: Unknown generator option: " + options[i].first;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment