feat: Implement binary_toolchain#875
Open
BoleynSu wants to merge 2 commits intobazel-contrib:mainfrom
Open
Conversation
f160c2a to
f586477
Compare
f586477 to
bb34827
Compare
853bd53 to
09874f1
Compare
09874f1 to
e49384b
Compare
e49384b to
6fcde2f
Compare
This was referenced Jul 1, 2024
alexeagle
reviewed
Jul 12, 2024
Collaborator
There was a problem hiding this comment.
This seems very similar to bazel-contrib/rules_oci#590 by @EdSchouten
I wonder if bazel-lib could provide the abstraction that's needed for this case globally. We should bike-shed on this name because "BinaryInfo" can also apply to a binary run as an action on the exec platform.
Author
There was a problem hiding this comment.
Agree we should have the abstraction shared. binary_toolchain is my answer. While there are still some decision we want to make which are not clear to me yet.
I think ideally we only limit the scope of the solution to 2) in bazelbuild/bazel#19645 (comment)
Then we only need to have one toolchain_type for the binary. Using jq as an example.
We will need
toolchain_type(name = "jq_binary_toolchain_type") # User should register different binary to this toolchain
binary_toolchain(name="jq_linux_amd64", binary="@jq_linux_amd64")
toolchain(
name = "toolchain_linux_amd64",
toolchain = ":jq_linux_amd64",
toolchain_type = :jq_binary_toolchain_type",
target_compatible_with = linux_amd64,
)
resolved_binary(name = "resolved_jq_binary") # This resolves to a binary that run on the target platform
# The jq_toolchain_type will be made private regarding registering, i.e. we only register jq_toolchain to it and do not allow user to register new toolchain to jq_toolchain_type.
toolchain_type(name = "jq_toolchain_type")
jq_toolchain(name = "jq_toolchain") # jq_toolchain use resolved_jq_binary with cfg=exec
toolchain(
name = "toolchain",
toolchain = ":jq_toolchain",
toolchain_type = :jq_toolchain_type",
)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See #747