-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Redeclaring imported protos #74
Comments
Is this a correct understanding of your scenario: You compile It is a good question, and it ties in with name resolution, knowing if a referred-to type, possibly in an imported proto file, is an enum or another message, for example. The gpb works the way it reads and imports all protos to get one coherent view of all definitions, then it generates one A different approach to the code generation altogether could of course be to generate one |
I should maybe also add that the current way of reading all imported proto files to get one unified view, and then generate only one Generating one It is of course possible to support one |
Right. This is a big complicated to explain, hehe, I'm looking to convert our plugin at work to use gpb instead of a mix of erlang_protobuffs and custom code. Currently it does create a Essentially we have a What we do for protos with multiple messages defined is automatically namespace them with the name of the proto, so we get Kind of hacky :) but it works pretty well for namespacing in Erlang for us. |
Hmm... I think I see the problem you're facing. I was first thinking a more general name transformation function could be useful (some addition to the |
Yea, sadly it seems because msgs are just a tuple |
That's right (maps would have been welcome, had they existed when I began with gpb :) ) A way could be to do it in a way similar to how proto3 messages are tracked in a |
I was toying with an idea to have an option, |
Was thinking that |
Hm, yea, that would be nice and workable. |
That worked perfectly and was easily implemented :). I'll clean up all my 3 changes (I also have the snake_case update) and get you a PR of 3 commits today most likely. |
Curious, why not support something like:
Directly in the |
Argh, does |
It does save some proto options, and just throws away most, unfortunately. But I figure it might be better to have this kind of configuration outside of the proto file for two reasons: (a) it might differ from use case to use case --- I originally added prefixing and suffixing imgaining it as a way to avoid name collisions eg in a larger project combining two proto sub projects, and (b) I think people sometimes want to include the proto files to the Erlang verbatim with absolutely no change (eg easier comparison that two sides are running with the same definitions), yet still they might want to have prefixing or suffixing or such. |
Sorry, re-reading, I understand you mean Google's protobuf compiler, I've no idea what it does, but I, too would expect it to just ignore unknown options. There are also some kind of custom options that might be related, but I haven't spent much time looking into that. |
I merged your |
Why are imported protos redeclared in the generated code for the protos that import them?
Meaning for proto
a.proto
withimport b.proto
whereb.proto
containsmessage B { ...}
and I havemsg_name_prefix
set to the name of the proto file I find that ina.erl
anda.hrl
the record#a_b{}
which is a duplicate of#b{}
.Shouldn't it simply use
b.hrl
andb.erl
froma
? Or at the very least ignore themsg_name_prefix
when importing protos?The text was updated successfully, but these errors were encountered: