-
-
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
[internal] Add plugin hook for Go codegen support #14707
Conversation
It's not sufficient for compiled languages. We'll need a new plugin hook instead. Still keep a dedicated rule for generating the source files though. That is nice for readability and testing. # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
This comment was marked as outdated.
This comment was marked as outdated.
) | ||
|
||
# Running directly on a codegen target should work. | ||
assert_pkg_target_built( |
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.
Note that this triggers actual Go compilation - it works 🙌
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.
Nice!
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
) | ||
|
||
# Running directly on a codegen target should work. | ||
assert_pkg_target_built( |
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.
Nice!
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
0b3f073
to
0026798
Compare
…e codegen # Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
PTAL at the newest commit to make sure it's okay. I made the test more complex to ensure we can handle codegen depending on |
# Rust tests and lints will be skipped. Delete if not intended. [ci skip-rust] # Building wheels and fs_util will be skipped. Delete if not intended. [ci skip-build-wheels]
Closes #14258. As described there, codegen for compiled languages is more complex because the generated code must be compiled, unlike Python where the code only needs to be present.
We still use the
GenerateSourcesRequest
plugin hook to generate the raw.go
files and so that integrations likeexport-codegen
goal still work. But that alone is not powerful enough to know how to compile the Go code.So, we add a new Go-specific plugin hook. Plugin implementations return back the standardized type
BuildGoPackageRequest
, which is all the information needed to compile a particular package, including by compiling its transitive dependencies. That allows for complex codegen modeling such as Protobuf needing the Protobuf third-party Go package compiled first, or Protobufs depending on other Protobufs.Rule authors can then directly tell Pants to compile that codegen (#14705), or it can be loaded via a
dependency
on a normalgo_package
.