-
Notifications
You must be signed in to change notification settings - Fork 439
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
Platform transition added to Rust binary rules. #2310
Conversation
7f62a13
to
aad11db
Compare
Tagged folks - @aiuto @katre @fmeum - I know there's been long-standing discussion around flagless builds and arbitrary targets being transitionable - this PR seems like a reasonable step in that direction, but feels like a very specific instance/implementation of a very general pattern... Any thoughts on whether we should do this as-is, and whether there's anything we should change to be forwards-compatible with any larger more general efforts folks may be considering? |
This change is compatible with our goals, as outlined in Standard Platforms Transitions. Once we have the common |
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.
LGTM!
I'll leave this open for a day or two in case any other maintainers have thoughts.
@katre thanks for the link. I'd be happy to switch this over to |
aad11db
to
3c76a71
Compare
64230fe
to
752d01c
Compare
752d01c
to
0858b64
Compare
0858b64
to
0be9203
Compare
Without much insight into core Bazel's plans for supporting "flagless" builds across platforms, this seems like the most direct way to select the platform for a given Rust binary target (all the terminal rules) that doesn't need additional work to forward providers.
Currently I'm using
platform_transition_binary
(https://github.com/aspect-build/bazel-lib/blob/main/docs/transitions.md), but it doesn't work with Rust Analyzer/Clippy/etc. presumably due to not forwarding the providers. In the case of this particular rule, it also doesn't work for something likerust_shared_library()
which is explicitly not anexecutable = True
target.@illicitonion brought to my attention
with_cfg
(https://github.com/fmeum/with_cfg.bzl) which could be used as an alternative by consumers ofrules_rust
instead of this PR. That feels reasonable, though certainly more work for individual users and appears to rely on a lot of Bazel black magic.Along the same lines, this could wait on rule inheritance as presumably a more formally supported
with_cfg
approach, which would also be up to individual users and notrules_rust
.Tagging @aiuto, @katre, and @comius per @illicitonion's suggestion of relevant inputs 🙂