-
-
Notifications
You must be signed in to change notification settings - Fork 638
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
generate and compile Go from Protobuf #14714
Conversation
|
Yep. Fixed. Thanks for the report 🙌
Yes. This will look like #14693, but Golang-ier. We still need to figure out how you refer to that
I think so, and indeed Pants dep inference already handles inter-Protobuf dependencies. But I also think this highly relates to your question 2. It seems possible that inter-Protobuf dependencies might end up belonging to the same package? If so, they need to be built together — not via a direct dependency.
We should, but also I think "sibling" isn't relevant here, right? It is possible for a protobuf_source file implemented in dir1/ to set the same import path as dir2/, even though not siblings. I think we will need to create a module mapping of each import path to set of Protobuf files. That set needs to behave as an atomic unit. It's convenient that this module mapping is the same way we will implement dependency inference from Go -> Protobuf! If Go imports a generated package, we must infer a dep on all protobuf_source targets that are part of the package: the whole set. Question @tdyas, do we expect that users will need to set the Generally, it's valuable for Pants to try to stay closer to the standard way of doing things: that you can still use normal Protoc if you want. This is important for incremental adoption. Which would suggest it's better for people to set the option in their We could also start with requiring you to add it, and if users find that too restrictive we can consider loosening this. Easier to make less strict than vice versa. |
Via the import path for the module? |
Possibly! That would not fit well with the generic (It's probably better to discuss multiple go.mod at #13114. It shouldn't block this PR, so long as #14693 is viable.) |
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
e627c3b
to
d737211
Compare
[ci skip-rust] [ci skip-build-wheels]
[ci skip-rust] [ci skip-build-wheels]
This is ready for review. The rules infer dependencies from generated Go code to existing Go packages (including the protobuf runtime) and dependencies on other Go Protobuf packages. |
cc @chrisjrn in case there anything relevant here for JVM rules |
ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Eric-Arellano should probably still review, but here's my stamp.
@rule | ||
async def setup_build_go_package_request_for_protobuf( | ||
_: GoCodegenBuildProtobufRequest, | ||
request: GoCodegenBuildProtobufRequest, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Eric-Arellano: Relative to #14751, I'm still not quite sure why Go needs a union separate from the GenerateSourcesRequest
union, which already indicates that code can be generated for Go.
A lot of work went in here, and I won't block. But it would be good to be sure that it is necessary relative to using an existing BuildGoPackageRequest
with a target which "can be converted to" Go, rather than one that already has matching field(sets) (i.e.: this code becoming codegen aware rather than using direct field access).
The inference @rules
(on the other hand) do seem necessarily custom, since they map from protobuf sources to a Go path.
package_mapping: ImportPathToPackages, | ||
go_protobuf_mapping: GoProtobufImportPathMapping, | ||
analyzer: PackageAnalyzerSetup, | ||
) -> BuildGoPackageRequest: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this return a FallibleBuildGoPackageRequest
to fail slow here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I realized this was a bad call on my part when adding the plugin API - we want ./pants check ::
to fail gracefully. I think it's fine to fix this is a followup, given that it's changing the generic plugin hook
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do in follow-up.
Complete Go protobuf support by actually wiring up compilation of the generated Go sources.
Closes #12820.
[ci skip-rust]
[ci skip-build-wheels]