Skip to content

Commit

Permalink
Merge pull request #9121 from haberman/rubyfix
Browse files Browse the repository at this point in the history
Fix for descriptor_pb.rb: google/protobuf should be required first.
  • Loading branch information
haberman committed Oct 20, 2021
2 parents 51cb7f9 + bb5a268 commit 912eb8b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/google/protobuf/compiler/ruby/ruby_generated_code_pb.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions src/google/protobuf/compiler/ruby/ruby_generator.cc
Expand Up @@ -467,8 +467,6 @@ void EndPackageModules(int levels, io::Printer* printer) {

bool GenerateDslDescriptor(const FileDescriptor* file, io::Printer* printer,
std::string* error) {
printer->Print(
"require 'google/protobuf'\n\n");
printer->Print("Google::Protobuf::DescriptorPool.generated_pool.build do\n");
printer->Indent();
printer->Print("add_file(\"$filename$\", :syntax => :$syntax$) do\n",
Expand Down Expand Up @@ -509,8 +507,13 @@ bool GenerateFile(const FileDescriptor* file, io::Printer* printer,
"\n",
"filename", file->name());

for (int i = 0; i < file->dependency_count(); i++) {
printer->Print("require '$name$'\n", "name", GetRequireName(file->dependency(i)->name()));
printer->Print("require 'google/protobuf'\n\n");

if (file->dependency_count() != 0) {
for (int i = 0; i < file->dependency_count(); i++) {
printer->Print("require '$name$'\n", "name", GetRequireName(file->dependency(i)->name()));
}
printer->Print("\n");
}

// TODO: Remove this when ruby supports extensions for proto2 syntax.
Expand Down

0 comments on commit 912eb8b

Please sign in to comment.