-
Notifications
You must be signed in to change notification settings - Fork 511
Improve proc_macro_deps ergonomics, take 3 #3605
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
crate_info = dep[rust_common.crate_info] if rust_common.crate_info in dep else None, | ||
dep_info = dep[rust_common.dep_info] if rust_common.crate_info in dep else None, | ||
crate_info = dep[CrateInfo] if CrateInfo in dep else None, | ||
dep_info = dep[DepInfo] if DepInfo in dep else None, |
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.
cleaned up provider references while I was here and discovered dep_info
was cheking for the CrateInfo provider but using DepInfo one :)
5a6ee86
to
662ca6d
Compare
662ca6d
to
bed15ce
Compare
I love this. |
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.
How does this handle transitioning proc_macro_deps
to exec
?
rules_rust/rust/private/rust.bzl
Lines 726 to 736 in 12762a7
# Previously `proc_macro_deps` were a part of `deps`, and then proc_macro_host_transition was | |
# used into cfg="host" using `@local_config_platform//:host`. | |
# This fails for remote execution, which needs cfg="exec", and there isn't anything like | |
# `@local_config_platform//:exec` exposed. | |
"proc_macro_deps": attr.label_list( | |
doc = dedent("""\ | |
List of `rust_proc_macro` targets used to help build this library target. | |
"""), | |
cfg = "exec", | |
providers = [rust_common.crate_info], | |
), |
That line you linked is still there, that's how it works :). Basically the wrapper macro sends all deps to both dep (target configured) and proc_macro_deps (exec configured) on the underlying rules, and then 'filter_deps' discards the unnecessary ones. The first commit is the best one to look at, the rest are fairly mechanical |
Ah, I see now. This directionally seems wrong (even though I see the ergonomics of it). Will this impact |
I wasn't able to measure any significant difference in our repo; there is very minimal processing of the extra deps and rules_rust already does a ton of expensive analysis work so it's lost in the noise
I'm prototyping some cargo-related repository rules / module extensions and it's hard to emit the https://bazelbuild.slack.com/archives/CSV56UT0F/p1726290118173529 also brought up the point that needing to treat proc_macros specially also complicated BUILD generation logic
Could you elaborate more on this? To me it feels good to not force every consumer to categorize deps into the right slots, after all we allow CcInfo-carrying targets into |
We can stop forcing users to sort their deps into
deps
andproc_macro_deps
; instead all deps are supplied todeps
in the public macros and the rules sort it out.Best reviewed commit by commit.
I kept the
proc_macro_deps
attribute named the same just in case, but it would be nice to rename toexec_configured_deps
at some point to reflect reality.Fixes #2893