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

Accept rust_library_group in proc_macro_deps #2900

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ def _assert_correct_dep_mapping(ctx):
),
)
for dep in ctx.attr.proc_macro_deps:
type = dep[rust_common.crate_info].type
if type != "proc-macro":
fail(
"{} listed {} in its proc_macro_deps, but it is not proc-macro, it is a {}. It should probably instead be listed in deps.".format(
ctx.label,
dep.label,
type,
),
)
if rust_common.crate_info in dep:
type = dep[rust_common.crate_info].type
if type != "proc-macro":
fail(
"{} listed {} in its proc_macro_deps, but it is not proc-macro, it is a {}. It should probably instead be listed in deps.".format(
ctx.label,
dep.label,
type,
),
)

def _rust_library_impl(ctx):
"""The implementation of the `rust_library` rule.
Expand Down Expand Up @@ -647,7 +648,7 @@ _common_attrs = {
List of `rust_proc_macro` targets used to help build this library target.
"""),
cfg = "exec",
providers = [rust_common.crate_info],
providers = [[rust_common.crate_group_info], [rust_common.crate_info]],
Copy link
Collaborator

Choose a reason for hiding this comment

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

This accepts crate_group_info providers, but then doesn't look for them? I think you'd need a second branch in the if you added which looks for crate_group_info and if it's present, iterates across them to look in their crate_info values?

Please could you add a test which uses this functionality, so we can see the code definitely works?

),
"rustc_env": attr.string_dict(
doc = dedent("""\
Expand Down