-
Notifications
You must be signed in to change notification settings - Fork 15.4k
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
Add CLI flag --schemas_out to turn descriptor set back to .protos #4021
Add CLI flag --schemas_out to turn descriptor set back to .protos #4021
Conversation
Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok for us to run on our infrastructure. |
1 similar comment
Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok for us to run on our infrastructure. |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
From what I can tell, this is not a common use case of protoc. The interaction between existing protoc command line flags are already complicated and I'm concerned about adding more. Can you instead just use the DescriptorPool API in your schema generator? The implementation should be pretty straightforward as shown by Kenton on the stackoverflow question. |
I suspect it's not a common use case, true. It seems fitting as an inverse to the existing I'm not sure how the DescriptorPool API alone would help with my use case. I use essentially Kenton's implementation in this PR, and it seems to require the C++-only DebugString method as well. Can I produce actual .proto schemas by that means without C++? |
Converting descriptors to proto syntax is only supported in C++ API. If you are using some other language, it should still be easy enough to write a dedicated C++ binary for this purpose. Also I think you can consider using the descriptor set directly without generating intermediate .proto files since protoc (and proto runtime) can make use of the descriptor set without relying on actual .proto files. |
I have, in fact, written a dedicated C++ binary, but I thought it might be useful to others to have it in protoc. If not, ok. |
We are moving protobuf to its own organization (see #4796) and after that we should be able to use a separate repo to build a more feature-rich command line tool instead of stretching protoc. |
Hey @djudd-stripe. It has been a while since this post but was wondering if you could perhaps provide the code for the C++ binary that you built? Even though I would have appreciated the functionality you suggested in this PR, providing the code can at least help people like me to find alternatives. |
@ruanspies I believe this was it: https://gist.github.com/djudd-stripe/721edf9fa42edeccd8a786faae4e365c |
This is a proposed feature, on which I'm looking for comment. I haven't implemented tests yet, but will if folks like the idea.
The main use case I have is generating .proto schemas from another, canonical schema definition. Rather than writing out .proto strings myself, it seems safer/nicer to build a descriptor set object using standard setters and then use google/protobuf C++ code to turn that into .proto strings, and I'm not working in C++ so would like to be able to shell out to protoc.
Evidence that I'm not the only person who has wanted this feature: https://stackoverflow.com/questions/19418655/restoring-proto-file-from-descriptor-string-possible
I should be covered by the Stripe CLA, although the bot doesn't always seem to recognize that.