Skip to content

Commit

Permalink
Fixed genquery for rust targets (#2559)
Browse files Browse the repository at this point in the history
relates to #2522
  • Loading branch information
UebelAndre committed Mar 26, 2024
1 parent 00a4bfb commit 98fab85
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 4 deletions.
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();
}

0 comments on commit 98fab85

Please sign in to comment.