Skip to content

Commit c8ff253

Browse files
authored
wd_rust_crate improvements (#5180)
- proper include prefix - @expand manual target to debug proc macros (if there are any)
1 parent fd37875 commit c8ff253

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

build/wd_rust_crate.bzl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test")
1+
load("@rules_rust//rust:defs.bzl", "rust_library", "rust_test", "rust_unpretty")
22

33
def rust_cxx_bridge(
44
name,
@@ -87,13 +87,15 @@ def wd_rust_crate(
8787
"@workerd-cxx//:cxx",
8888
]
8989

90+
include_prefix = "workerd/" + native.package_name().removeprefix("src/")
91+
9092
hdrs = native.glob(["**/*.h"], allow_empty = True)
9193
for bridge_src in cxx_bridge_srcs:
9294
rust_cxx_bridge(
9395
name = bridge_src + "@cxx",
9496
src = bridge_src,
9597
hdrs = hdrs,
96-
include_prefix = "workerd/rust/" + name,
98+
include_prefix = include_prefix,
9799
strip_include_prefix = "",
98100
# Not applying visibility here – if you import the cxxbridge header, you will likely
99101
# also need the rust library itself to avoid linker errors.
@@ -139,3 +141,10 @@ def wd_rust_crate(
139141
"//conditions:default": 1,
140142
}),
141143
)
144+
145+
if len(proc_macro_deps) + len(cxx_bridge_srcs) > 0:
146+
rust_unpretty(
147+
name = name + "@expand",
148+
deps = [":" + name],
149+
tags = ["manual", "off-by-default"],
150+
)

0 commit comments

Comments
 (0)