Use aspect to infer proto deps automatically
What type of PR is this?
Feature
What does this PR do? Why is it needed?
This automatically infers transitive proto deps with an aspect to avoid manually maintaining two parallel dependency trees (proto deps and go_proto deps).
Which issues(s) does this PR fix?
Fixes #3668
Other notes for review
Testing repository: https://github.com/mering/test-rules-go
@fmeum Could I have your input on this? I am quite new to Bazel and therefore any input is highly appreciated!
The approach in this PR is to generate the go proto bindings within an aspect on the proto_library rules instead of on a go_proto_library rule. One problem I am facing because of this is that it is now no longer possible to pass down attributes to the aspect. So one could either overwrite defaults (like importpath) on the proto_library rule instead of the go_proto_library one and access it somehow from there. Another alternative could be to use something like an importpath_prefix on a package level or similar. Same problem for compilers which are essential (e.g. for gRPC). I have seen some TODO comments regarding gRPC, so it probably makes sense to align with your plans as this will probably be a breaking change anyways.
So any input to my general approach or ideas on how to move forward is highly appreciated!
One idea which I just had is to use separate aspects for compilers (might still share the same implementation but need to set the _compiler attribute differently). Then the go_proto_library rule would just attach the proto aspect while the go_grpc_library would attach both the proto and the grpc aspect. Could this work?
@fmeum I would really appreciate your help here. Thanks in advance!
@fmeum I would really appreciate your help here. Thanks in advance!
Sorry for the delay, I do really appreciate your work on this. I can't promise that I will get to this before BazelCon as I'm somewhat busy preparing for it. I am not that knowledgeable about gRPC, so I will have to delve into that a bit before I can provide meaningful input.
CC @linzhp just in case you already have some ideas in mind
@fmeum I would really appreciate your help here. Thanks in advance!
Sorry for the delay, I do really appreciate your work on this. I can't promise that I will get to this before BazelCon as I'm somewhat busy preparing for it. I am not that knowledgeable about gRPC, so I will have to delve into that a bit before I can provide meaningful input.
Thanks for your answer. Take your time. Looking forward for your comments.
The approach in this PR is to generate the go proto bindings within an aspect on the proto_library rules instead of on a go_proto_library rule
proto_library rule should be language agnostic. You should pass any information related to Go in go_proto_library and its aspect. One implementation you can refer to is the py_proto_library in rules_python.
The approach in this PR is to generate the go proto bindings within an aspect on the proto_library rules instead of on a go_proto_library rule
proto_libraryrule should be language agnostic. You should pass any information related to Go ingo_proto_libraryand its aspect. One implementation you can refer to is thepy_proto_libraryin rules_python.
Isn't this exactly what I am doing? I tried to base my implementation on the Python one... Please correct me if I mix things up or chose the wrong words as I am still quite new to Bazel and especially aspects.