Index: third_party/protobuf/src/google/protobuf/compiler/java/java_generator.cc |
diff --git a/third_party/protobuf/src/google/protobuf/compiler/java/java_generator.cc b/third_party/protobuf/src/google/protobuf/compiler/java/java_generator.cc |
index 745b55ae15f948ab4f1a49d4e2092dbe8592dff2..e6c79abcd1a2040c974d6d58e48be6e35796e241 100644 |
--- a/third_party/protobuf/src/google/protobuf/compiler/java/java_generator.cc |
+++ b/third_party/protobuf/src/google/protobuf/compiler/java/java_generator.cc |
@@ -51,11 +51,8 @@ JavaGenerator::~JavaGenerator() {} |
bool JavaGenerator::Generate(const FileDescriptor* file, |
const string& parameter, |
- OutputDirectory* output_directory, |
+ GeneratorContext* context, |
string* error) const { |
- vector<pair<string, string> > options; |
- ParseGeneratorParameter(parameter, &options); |
- |
// ----------------------------------------------------------------- |
// parse generator options |
@@ -63,6 +60,10 @@ bool JavaGenerator::Generate(const FileDescriptor* file, |
// per line. |
string output_list_file; |
+ |
+ vector<pair<string, string> > options; |
+ ParseGeneratorParameter(parameter, &options); |
+ |
for (int i = 0; i < options.size(); i++) { |
if (options[i].first == "output_list_file") { |
output_list_file = options[i].second; |
@@ -72,18 +73,23 @@ bool JavaGenerator::Generate(const FileDescriptor* file, |
} |
} |
- |
// ----------------------------------------------------------------- |
+ if (file->options().optimize_for() == FileOptions::LITE_RUNTIME && |
+ file->options().java_generate_equals_and_hash()) { |
+ *error = "The \"java_generate_equals_and_hash\" option is incompatible " |
+ "with \"optimize_for = LITE_RUNTIME\". You must optimize for " |
+ "SPEED or CODE_SIZE if you want to use this option."; |
+ return false; |
+ } |
+ |
FileGenerator file_generator(file); |
if (!file_generator.Validate(error)) { |
return false; |
} |
- string package_dir = |
- StringReplace(file_generator.java_package(), ".", "/", true); |
- if (!package_dir.empty()) package_dir += "/"; |
+ string package_dir = JavaPackageToDir(file_generator.java_package()); |
vector<string> all_files; |
@@ -94,19 +100,19 @@ bool JavaGenerator::Generate(const FileDescriptor* file, |
// Generate main java file. |
scoped_ptr<io::ZeroCopyOutputStream> output( |
- output_directory->Open(java_filename)); |
+ context->Open(java_filename)); |
io::Printer printer(output.get(), '$'); |
file_generator.Generate(&printer); |
// Generate sibling files. |
- file_generator.GenerateSiblings(package_dir, output_directory, &all_files); |
+ file_generator.GenerateSiblings(package_dir, context, &all_files); |
// Generate output list if requested. |
if (!output_list_file.empty()) { |
// Generate output list. This is just a simple text file placed in a |
// deterministic location which lists the .java files being generated. |
scoped_ptr<io::ZeroCopyOutputStream> srclist_raw_output( |
- output_directory->Open(output_list_file)); |
+ context->Open(output_list_file)); |
io::Printer srclist_printer(srclist_raw_output.get(), '$'); |
for (int i = 0; i < all_files.size(); i++) { |
srclist_printer.Print("$filename$\n", "filename", all_files[i]); |