-
-
Notifications
You must be signed in to change notification settings - Fork 163
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
Support --include_source_info
#38
Comments
Unfortunately it's not as easy as just adding the argument:
|
These rules consume the descriptors generated by the builtin (or sourced from bazelbuild/rules_proto) I'm marking this issue as blocked, as I don't think there's much this repo can do without upstream support first. In theory we could regenerate descriptors ourselves from the info in the ProtoInfo provider, but then we'd be replicating all of the behaviour/work of Do you have examples of plugins that fail with the existing behaviour? |
stackb/rules_proto also consumes native |
I believe this is the key. The original repo would not use descriptors and would pass source files directly with Perhaps you could introduce a per-plugin config that uses source files instead of input descriptors? It would be slower, but more feature rich. It can be done by using |
That may be reasonable, although |
Right, it could get transitive descriptors from dependencies and only recompile direct sources. Thank you for looking into this! |
This could be solved by bazelbuild/bazel#9337, which is about including source info in the descriptor-sets by default. |
Ah excellent, I had been meaning to check if there's an issue open regarding this. Thanks for the link. In which case, I'd rather not have to support two paths within the aspect for descriptor vs direct compilation, if this is the only use case highlighted thus far for the latter. However, I should be able to get a branch working for this as an intermediary solution, but I won't plan on merging those changes to master. |
Shouldn't it be sufficient to add [1] https://docs.bazel.build/versions/master/command-line-reference.html#flag--protocopt |
The flag would work, but when you have a lot of protos it would slow down many plugins that don't need the source infos. This is actually why I was advocating for having the two paths -- it would be nice to support both. Global variables are not great for that. I see two ways right now:
|
It'd be useful to have some concrete numbers on the impact of enabling source info on large codebases, as mentioned in the above issue comments. Finding a repo with stacks of proto files would be a good benchmark, perhaps https://github.com/googleapis/api-common-protos? As I see it, we have four 'modes' that could be supported:
Modes 1 and 2 are supported today, with mode 2 requiring the protocopt flag presently but possibly being the default One of the benefits of using descriptors is that you pay all the IO and parsing cost of reading the proto files once. On the other hand, the 'direct' modes (3 & 4) require reading every proto file for each |
Possibly. Though when you add source info to the descriptor set, it basically becomes as large as the source file, so there are no IO savings, just the parsing time saving. In any case, |
Sorry, that wasn't too clear: I meant that the IO latency of opening, reading, parsing and closing multiple small files may be slower than the same for one big file. |
Actually the style guide says you should generally have one proto file |
Just want to add that the proposed
|
Since the move to non-transitive mode in 3.0.0, it's now a lot easier to support this. Therefore, in the next release I'm adding a plugin option to pass the files and import paths directly to the protoc invocation (effectively mode 4 above). This allows plugins to directly see the proto files they are working on, rather than indirectly via descriptors. |
Original stackb repository supports configuring it for all rules. See java example.
This is a big issue for plugins that want to generate code preserving documentation.
The text was updated successfully, but these errors were encountered: