Skip to content

Commit

Permalink
pw_build: Add mod proc_macro to rust macro targets
Browse files Browse the repository at this point in the history
Gnaw which translates Cargo.toml to GN does not reads the `lib` section
in Cargo manifest. Some crates puts `proc_macro` in `lib` and does not
specify `use proc_macro` in the source. This change is a workaround for
building those crates.

Change-Id: I1cec9b076931e5175068781cfd3e9c1aefa2f86c
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/230013
Commit-Queue: Jiacheng Lu <[email protected]>
Reviewed-by: Erik Gilling <[email protected]>
Lint: Lint 🤖 <[email protected]>
  • Loading branch information
Jason0214 authored and CQ Bot Account committed Aug 21, 2024
1 parent d0655bf commit 234632d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pw_build/rust_proc_macro.gni
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ template("pw_rust_proc_macro") {
pw_toolchain_SCOPE.is_host_toolchain) {
pw_rust_library(target_name) {
forward_variables_from(invoker, "*")

if (!defined(rustflags)) {
rustflags = []
}

rustflags += [
"--extern",
"proc_macro",
]
underlying_target_type = "rust_proc_macro"
}
} else {
Expand Down

0 comments on commit 234632d

Please sign in to comment.