Skip to content

Commit 6c09dde

Browse files
author
Adam Cozzette
committed
Sync from Piper @388508285
PROTOBUF_SYNC_PIPER
1 parent 9b65c2c commit 6c09dde

3 files changed

Lines changed: 15 additions & 36 deletions

File tree

README.md

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
Protocol Buffers - Google's data interchange format
22
===================================================
33

4-
[![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/linux-javascript.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fubuntu%2Fjavascript%2Fcontinuous) [![Build status](https://storage.googleapis.com/protobuf-kokoro-results/status-badge/macos-javascript.png)](https://fusion.corp.google.com/projectanalysis/current/KOKORO/prod:protobuf%2Fgithub%2Fmaster%2Fmacos%2Fjavascript%2Fcontinuous)
5-
64
Copyright 2008 Google Inc.
75

86
This directory contains the JavaScript Protocol Buffers runtime library.
@@ -94,11 +92,8 @@ statements like:
9492

9593
var message = proto.my.package.MyMessage();
9694

97-
If unfamiliar with Closure or its compiler, consider reviewing Closure documentation
98-
https://developers.google.com/closure/library/docs/tutorial
99-
https://developers.google.com/closure/library/docs/closurebuilder
100-
https://developers.google.com/closure/library/docs/depswriter
101-
At a high level, closurebuilder.py can walk dependencies, and compile your code, and all dependencies for Protobuf into a single .js file. Using depsbuilder.py to generate a dependency file can also be considered for non-production dev environments.
95+
If unfamiliar with Closure or its compiler, consider reviewing
96+
[Closure documentation](https://developers.google.com/closure/library).
10297

10398
CommonJS imports
10499
----------------

src/google/protobuf/compiler/js/js_generator.cc

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,24 +1412,17 @@ bool HasFieldPresence(const GeneratorOptions& options,
14121412
// were the final one for a given filename.
14131413
class FileDeduplicator {
14141414
public:
1415-
explicit FileDeduplicator(const GeneratorOptions& options)
1416-
: error_on_conflict_(options.error_on_name_conflict) {}
1415+
explicit FileDeduplicator(const GeneratorOptions& options) {}
14171416

14181417
// params:
14191418
// filenames: a pair of {short filename, full filename}
14201419
// (short filename don't have extra information, full filename
14211420
// contains extra information)
14221421
// desc: The Descriptor or SCC pointer or EnumDescriptor.
1423-
// error: The returned error information.
14241422
bool AddFile(const std::pair<std::string, std::string> filenames,
1425-
const void* desc, std::string* error) {
1423+
const void* desc) {
14261424
if (descs_by_shortname_.find(filenames.first) !=
14271425
descs_by_shortname_.end()) {
1428-
if (error_on_conflict_) {
1429-
*error = "Name conflict: file name " + filenames.first +
1430-
" would be generated by two descriptors";
1431-
return false;
1432-
}
14331426
// Change old pointer's actual name to full name.
14341427
auto short_name_desc = descs_by_shortname_[filenames.first];
14351428
allowed_descs_actual_name_[short_name_desc] =
@@ -1447,7 +1440,6 @@ class FileDeduplicator {
14471440
}
14481441

14491442
private:
1450-
bool error_on_conflict_;
14511443
// The map that restores all the descs that are using short name as filename.
14521444
std::map<std::string, const void*> descs_by_shortname_;
14531445
// The final actual filename map.
@@ -1541,8 +1533,7 @@ struct DepsGenerator {
15411533
bool GenerateJspbAllowedMap(const GeneratorOptions& options,
15421534
const std::vector<const FileDescriptor*>& files,
15431535
std::map<const void*, std::string>* allowed_set,
1544-
SCCAnalyzer<DepsGenerator>* analyzer,
1545-
std::string* error) {
1536+
SCCAnalyzer<DepsGenerator>* analyzer) {
15461537
std::vector<const FileDescriptor*> files_ordered;
15471538
GenerateJspbFileOrder(files, &files_ordered);
15481539

@@ -1557,15 +1548,15 @@ bool GenerateJspbAllowedMap(const GeneratorOptions& options,
15571548
std::make_pair(
15581549
GetMessagesFileName(options, analyzer->GetSCC(desc), false),
15591550
GetMessagesFileName(options, analyzer->GetSCC(desc), true)),
1560-
analyzer->GetSCC(desc), error)) {
1551+
analyzer->GetSCC(desc))) {
15611552
return false;
15621553
}
15631554
}
15641555
for (int j = 0; j < files_ordered[i]->enum_type_count(); j++) {
15651556
const EnumDescriptor* desc = files_ordered[i]->enum_type(j);
15661557
if (!dedup.AddFile(std::make_pair(GetEnumFileName(options, desc, false),
15671558
GetEnumFileName(options, desc, true)),
1568-
desc, error)) {
1559+
desc)) {
15691560
return false;
15701561
}
15711562
}
@@ -1584,7 +1575,7 @@ bool GenerateJspbAllowedMap(const GeneratorOptions& options,
15841575
std::make_pair(
15851576
GetExtensionFileName(options, files_ordered[i], false),
15861577
GetExtensionFileName(options, files_ordered[i], true)),
1587-
files_ordered[i], error)) {
1578+
files_ordered[i])) {
15881579
return false;
15891580
}
15901581
}
@@ -3477,12 +3468,10 @@ bool GeneratorOptions::ParseFromOptions(
34773468
return false;
34783469
}
34793470
testonly = true;
3471+
34803472
} else if (options[i].first == "error_on_name_conflict") {
3481-
if (options[i].second != "") {
3482-
*error = "Unexpected option value for error_on_name_conflict";
3483-
return false;
3484-
}
3485-
error_on_name_conflict = true;
3473+
GOOGLE_LOG(WARNING) << "Ignoring error_on_name_conflict option, this "
3474+
"will be removed in a future release";
34863475
} else if (options[i].first == "output_dir") {
34873476
output_dir = options[i].second;
34883477
} else if (options[i].first == "namespace_prefix") {
@@ -3531,11 +3520,10 @@ bool GeneratorOptions::ParseFromOptions(
35313520

35323521
if (import_style != kImportClosure &&
35333522
(add_require_for_enums || testonly || !library.empty() ||
3534-
error_on_name_conflict || extension != ".js" ||
3535-
one_output_file_per_input_file)) {
3523+
extension != ".js" || one_output_file_per_input_file)) {
35363524
*error =
3537-
"The add_require_for_enums, testonly, library, error_on_name_conflict, "
3538-
"extension, and one_output_file_per_input_file options should only be "
3525+
"The add_require_for_enums, testonly, library, extension, and "
3526+
"one_output_file_per_input_file options should only be "
35393527
"used for import_style=closure";
35403528
return false;
35413529
}
@@ -3770,8 +3758,7 @@ bool Generator::GenerateAll(const std::vector<const FileDescriptor*>& files,
37703758
std::set<const Descriptor*> have_printed;
37713759
SCCAnalyzer<DepsGenerator> analyzer;
37723760
std::map<const void*, std::string> allowed_map;
3773-
if (!GenerateJspbAllowedMap(options, files, &allowed_map, &analyzer,
3774-
error)) {
3761+
if (!GenerateJspbAllowedMap(options, files, &allowed_map, &analyzer)) {
37753762
return false;
37763763
}
37773764

src/google/protobuf/compiler/js/js_generator.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ struct GeneratorOptions {
8383
add_require_for_enums(false),
8484
testonly(false),
8585
library(""),
86-
error_on_name_conflict(false),
8786
extension(".js"),
8887
one_output_file_per_input_file(false),
8988
annotate_code(false) {}
@@ -119,8 +118,6 @@ struct GeneratorOptions {
119118
// Create a library with name <name>_lib.js rather than a separate .js file
120119
// per type?
121120
std::string library;
122-
// Error if there are two types that would generate the same output file?
123-
bool error_on_name_conflict;
124121
// The extension to use for output file names.
125122
std::string extension;
126123
// Create a separate output file for each input file?

0 commit comments

Comments
 (0)