-
Notifications
You must be signed in to change notification settings - Fork 70
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 framework for writing lang_proto_library #6
Comments
The generator API in the design doc required that all binding generators are protoc-plugins. The main reasons for this decision were:
We should investigate whether there are alternatives to this drastical step. ProtoGenerator = provider(
fields = {
"display_name": "Optional. The name that's used in the progress message (e.g. C++).",
"language": "String. As in `--<language>_out` (only for generators built into protoc).",
"plugin": "Executable. The generator plugin. Required iff `language` is not set.",
"options": "Optional. Sequence of strings.".
"extra_inputs": "Optional. depset() of extra inputs for protoc (e.g. configuration files).",
},
)
def _generate(
actions,
proto_toolchain,
generator,
descriptor_sets,
protos,
output_root,
outputs = [],
extra_inputs = []):
"""Generates source files for `.proto` files.
Args:
actions: Required. Instance of `ctx.actions`.
proto_toolchain: Required. Toolchain, defined by `proto_toolchain`.
generator: Required. Instance of `ProtoGenerator`.
descriptor_sets: # Required: A set of `FileDescriptorSet` files.
protos: Required. Sequence of strings `[<import_path>, …]` of protos to
generate, e.g. coming from `proto_common.protos_to_generate()`.
output_root: Required. File or string. Output root for the generator.
outputs: Sequence of output files. Required iff `output_root` is a string.
extra_inputs: Optional. Optional. depset() of extra inputs for protoc
(e.g. configuration files).
Returns:
Nothing
"""
pass |
I'm not sure I understand how this would work. |
I don't think non-protoc based generators typically accept FileDescriptorSet as input. If you wan to transparently support both, don't you need to pass both the FileDescriptorSets and the .proto files for dependencies? |
Yes, ProtoGenerator would be returned by lang_proto_toolchain. You are right, for now, this only works for protoc-based generators. Non-protoc based generators may name command-line flags differently, at which point it gets way to complicated (what if there are non-protoc based generators that actually support FileDescriptorSets, but expect them to be passed as |
Oh, I misread "built into protoc" above. I thought you meant that foo_proto_library shouldn't assume that foo_proto_toolchain uses protoc. But you're saying that cc_proto_library shouldn't assume that it's using the cc generator compiled into protoc. Sounds good. |
(just thinking out loud here) It seems like |
I just ran into this issue. I've been working on something similar to what you proposed above, and it was working for custom languages. But I just tried to use it for generating js and discovered that there's no --js_opt flag. |
Coincidently, I was also trying it with Looking at the code, I see that some generators (e.g. C++) already allow |
I believe |
It would be very helpful to have a "framework" for writing
lang_proto_library
- orlang_grpc_library
-rules.Design goals:
proto_library
.{cc,java}_proto_library
(See lang_proto_aspect_impl: get_output_files does not work well with languages like Java Yannic/rules_proto#5 for a framework that doesn't fulfill this).I already have an idea how this framework could look like, but I hadn't had time to create a design doc for it. In the meantime, leave a comment if you feel like anything is missing.
The text was updated successfully, but these errors were encountered: