silentorbit/protobuf

Import/Include path

zeroZshadow opened this issue · 7 comments

Im having an issue where i import a file using import "somefile.proto";
In protoc i can provide the -I someincludedir to tell it where it can look for imports, but CodeGenerator does not have this.

This should be quite easy to add.

I've had a quick jab at this feature on my fork, but the issue is a bit less trivial then though.
As you are generating code for the imported message class.

Say i have a Info message which i import in 2 different proto files, then i run the code generator twice to create the files for these 2 messages.
Both generated files will now have a partial class of Info, causing the compiler to complain.

Can you run the code generator only once?
Try give both proto files as argument.

I can try in a bit.
In my case both proto files are in different directories and packages, so generating this list before running CodeGenerator.exe instead of my current for loop will be much more work (on windows).

I see it's not so easy.

It looks like we also need a way import without generating code for the imported files.

It's doable.

My only concern is that using the tool like this put a lot of responsibility on the user to call the tool on every imported .proto.

Let me know how this works.

gyf19 commented

+1