-
Couldn't load subscription status.
- Fork 15.9k
WIP: wire up prebuilt protoc toolchain #24115
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
base: main
Are you sure you want to change the base?
Conversation
Users can manually register this in their MODULE.bazel so that registration overrides the default, which is still building protoc from source.
|
|
||
| protoc = module_extension( | ||
| # TODO: replace version number here during release, maybe with git archive .gitattributes config | ||
| implementation = lambda module_ctx: create_all_toolchain_repos("prebuilt_protoc", "v33.0") |
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.
Does this have to know the version if there is only one set of hashes provided anyway?
If you do want them, you could get the version from module_ctx.modules (search for the protobuf module and get its version field).
| version = version, | ||
| ) | ||
|
|
||
| protoc = module_extension( |
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.
Use skylibs modules.as_extension so that this is marked reproducible and you get bazel mod tidy fixes for use_repo while developing protobuf.
| """Create lazy definitions to reference the pre-built protoc toolchains. | ||
| Ensures that Bazel only downloads required binaries for selected toolchains. | ||
| This follows guidance here: | ||
| https://docs.bazel.build/versions/main/skylark/deploying.html#registering-toolchains | ||
| " | ||
| Note that in order to resolve toolchains in the analysis phase | ||
| Bazel needs to analyze all toolchain targets that are registered. | ||
| Bazel will not need to analyze all targets referenced by toolchain.toolchain attribute. | ||
| If in order to register toolchains you need to perform complex computation in the repository, | ||
| consider splitting the repository with toolchain targets | ||
| from the repository with <LANG>_toolchain targets. | ||
| Former will be always fetched, | ||
| and the latter will only be fetched when user actually needs to build <LANG> code. | ||
| " | ||
| The "complex computation" in our case is simply downloading our pre-built protoc binaries. | ||
| This guidance tells us how to avoid that: we put the toolchain targets in the alias repository | ||
| with only the toolchain attribute pointing into the platform-specific repositories. |
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.
Can be dropped in favor of the two line comment on the toolchains attribute (but it would be worth adding the link to that comment)
Co-authored-by: Fabian Meumertzheim <[email protected]>
Upstreamed from my https://github.com/aspect-build/toolchains_protoc which provided this feature outside the protobuf repo.
Adds:
prebuilt_protoc_repoto fetch a protoc binary from GitHub releasesprebuilt_toolchains_repothat creates the "hub" letting Bazel's toolchain resolver download only for the execution platformprotoc.prebuilt_toolchainto wrap up the above for bzlmod usersThis needs work with @thesayyn to:
https://docs.google.com/document/d/16N-eU-0zHbWmxEuaUAIFTJwQLekIXZ8zIC3K4XDr20E/edit
Work towards #19558