-
Notifications
You must be signed in to change notification settings - Fork 483
Add a conditional implicit dependency on the import macro. #1151
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
Conversation
rust/private/utils.bzl
Outdated
@@ -399,6 +399,21 @@ def transform_deps(deps): | |||
cc_info = dep[CcInfo] if CcInfo in dep else None, | |||
) for dep in deps] | |||
|
|||
def create_import_macro_dep(ctx): |
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.
Nit: get_import_macro_deps
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.
Done
rust/private/transitions.bzl
Outdated
def _with_import_macro_bootstrapping_mode_impl(ctx): | ||
target = ctx.attr.target[0] | ||
providers = [target[rust_common.crate_info], target[rust_common.dep_info]] | ||
if hasattr(ctx, "executable") and hasattr(ctx.executable, "target"): |
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.
Could you remind me why is this necessary?
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.
Ack, this was a holdover from the previous attempt at this rule, which supported executable targets. No longer necessary since this is only used for lib targets.
646d172
to
6c60048
Compare
This is related to #1008 and #1013. This PR aims to improve the UX of the import macro by not requiring every target to explicitly depend on the macro.
This PR adds an implicit attribute to every
rust_library
andrust_binary
rule, which (if theuse_real_import_macro
flag is enabled) adds theimport
macro crate to the target'sproc_macro_deps
. If theuse_real_import_macro
flag is disabled (which is the default), the implicit attribute points to a no-op shell script, and nothing is added to the target's dependencies.