[protobuf] Issue 183 in protobuf: --java_out=output_list_file= parameter fails when compiling multiple proto files

904 views
Skip to first unread message

prot...@googlecode.com

unread,
Apr 28, 2010, 8:53:33 AM4/28/10
to prot...@googlegroups.com
Status: New
Owner: ken...@google.com
Labels: Type-Defect Priority-Medium

New issue 183 by t.broyer: --java_out=output_list_file= parameter fails
when compiling multiple proto files
http://code.google.com/p/protobuf/issues/detail?id=183

What steps will reproduce the problem?
Run protoc with multiple input files to generate Java and passing the
output_list_file parameter. For instance, derived from the command line
found in java/README.txt:

$ protoc --java_out=output_list_file=generated_files.txt:src/main/java \
-I../src ../src/google/protobuf/descriptor.proto \
../src/google/protobuf/compiler/plugin.proto

What is the expected output? What do you see instead?
generated.txt should contain the list of all generated files (in this case
two lines: com/google/protobuf/DescriptorProtos.java and
google/protobuf/compiler/PluginProtos.java), but instead protoc fails with
the following message:

generated_files.txt: Tried to write the same file twice.

What version of the product are you using? On what operating system?
2.3.0 on Windows XP (using the precompiled protoc.exe)

Please provide any additional information below.
This unfortunately is a flaw in the CodeGenerator architecture: a
CodeGenerator is called for each .proto file to generate and cannot
maintain state (in this case it would probably be the "vector<string>
all_files") between calls as there are no start/end hooks (to know when to
flush the list to the file).

The workaround is to invoke protoc repeatedly with only 1 .proto file and a
different output_list_file each time.

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups "Protocol Buffers" group.
To post to this group, send email to prot...@googlegroups.com.
To unsubscribe from this group, send email to protobuf+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.

prot...@googlecode.com

unread,
Apr 28, 2010, 1:31:13 PM4/28/10
to prot...@googlegroups.com

Comment #1 on issue 183 by ken...@google.com: --java_out=output_list_file=
parameter fails when compiling multiple proto files
http://code.google.com/p/protobuf/issues/detail?id=183

Yeah, this cannot be fixed without design changes.

Perhaps you could instead take advantage of .jar output mode? If you
output to a .jar, then you can enumerate
files in the .jar easily.

prot...@googlecode.com

unread,
Apr 28, 2010, 1:49:24 PM4/28/10
to prot...@googlegroups.com

Comment #2 on issue 183 by t.broyer: --java_out=output_list_file= parameter
fails when compiling multiple proto files
http://code.google.com/p/protobuf/issues/detail?id=183

I actually do not have a need for it myself, I just stumbled upon it while
working on
my Java-based plugin (where I want to output a file listing other files
generated by
each .proto file processed; namely a GWT module that <inherits/> the GWT
modules
generated for each .proto file), and it happened to me that it couldn't
have been done
in C++ using the CodeGenerator API (and PluginMain) only.

prot...@googlecode.com

unread,
Apr 28, 2010, 2:36:48 PM4/28/10
to prot...@googlegroups.com

Comment #3 on issue 183 by ken...@google.com: --java_out=output_list_file=
parameter fails when compiling multiple proto files
http://code.google.com/p/protobuf/issues/detail?id=183

Well, you're the first person ever to report this. I suspect no one
actually uses
this feature...

prot...@googlecode.com

unread,
Apr 29, 2010, 9:00:46 AM4/29/10
to prot...@googlegroups.com

Comment #4 on issue 183 by t.broyer: --java_out=output_list_file= parameter
fails when compiling multiple proto files
http://code.google.com/p/protobuf/issues/detail?id=183

In the event you'd like to fix this anyway, it might be as easy as adding a
new
method to CodeGenerator:
public:
virtual bool Generate(const vector<const FileDescriptor*>& parsed_files,
const string& parameter,
OutputDirectory* output_directory,
string* error);
to encapsulate the loop that's found in both
CommandLineInterface::GenerateOutput and
PluginMain (the latter function would need some refactoring to actually
build the
vector<const FileDescriptor*> out of the DescriptorPool and
CodeGeneratorRequest::file_to_generate) and that could be overridden (or
you could
make it non-virtual and provide start/end protected virtual methods as
hooks called
before and after the loop respectively). The current per-FileDescriptor
method would
likely become protected too.

prot...@googlecode.com

unread,
Oct 6, 2014, 3:09:45 PM10/6/14
to prot...@googlegroups.com
Updates:
Status: WontFix

Comment #6 on issue 183 by xiaof...@google.com:
--java_out=output_list_file= parameter fails when compiling multiple proto
files
https://code.google.com/p/protobuf/issues/detail?id=183

(No comment was entered for this change.)

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages