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

Fixed genquery for rust targets #2559

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -528,10 +528,6 @@ RUSTC_ATTRS = {
"_extra_rustc_flags": attr.label(
default = Label("//:extra_rustc_flags"),
),
"_import_macro_dep": attr.label(
default = Label("//util/import"),
cfg = "exec",
),
"_is_proc_macro_dep": attr.label(
default = Label("//rust/private:is_proc_macro_dep"),
),
Expand Down
3 changes: 3 additions & 0 deletions rust/private/utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,9 @@ def get_import_macro_deps(ctx):
list of Targets. Either empty (if the fake import macro implementation
is being used), or a singleton list with the real implementation.
"""
if not hasattr(ctx.attr, "_import_macro_dep"):
return []

if ctx.attr._import_macro_dep.label.name == "fake_import_macro_impl":
return []

Expand Down
26 changes: 26 additions & 0 deletions test/genquery/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
load("//rust:defs.bzl", "rust_binary", "rust_library")

rust_library(
name = "bar",
srcs = ["bar.rs"],
edition = "2021",
)

genquery(
name = "bar_deps",
expression = "deps(//test/genquery:bar)",
scope = [":bar"],
)

rust_binary(
name = "foo",
srcs = ["foo.rs"],
edition = "2021",
deps = [":bar"],
)

genquery(
name = "foo_deps",
expression = "deps(//test/genquery:foo)",
scope = [":foo"],
)
3 changes: 3 additions & 0 deletions test/genquery/bar.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn bar() {
println!("Bar");
}
4 changes: 4 additions & 0 deletions test/genquery/foo.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
println!("foo");
bar::bar();
}
Loading