Skip to content
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

feat: Implement binary_toolchain #875

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BoleynSu
Copy link

@BoleynSu BoleynSu commented Jul 1, 2024

See #747

@CLAassistant
Copy link

CLAassistant commented Jul 1, 2024

CLA assistant check
All committers have signed the CLA.

@BoleynSu BoleynSu changed the title Implement bnary_toolchain Implement binary_toolchain Jul 1, 2024
@BoleynSu BoleynSu force-pushed the binary_toolchain branch 2 times, most recently from 853bd53 to 09874f1 Compare July 1, 2024 08:18
@BoleynSu BoleynSu changed the title Implement binary_toolchain feat: Implement binary_toolchain Jul 1, 2024
Copy link
Collaborator

@alexeagle alexeagle Jul 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

@BoleynSu BoleynSu Jul 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants