assemble_crate now supports procedural macro dependencies, and is more reliable at correctly detecting the crate names of all dependencies. In particular, crates with hyphens (such as async-trait) should no longer cause issues.
What are the changes implemented in this PR?
Previously assemble_crate aggregated dependency info via only the deps attribute of a rust_* target. Now, proc_macro_deps is traversed as well.
Also, crate name detection has been reworked. Because rules_rust doesn't expose the original name of the crate downloaded from Cargo anywhere, we were unable to reliably get that crate name and put it into Cargo.toml. Now, we use string parsing against the target's label. This works because the label is (e.g):
@crates__async-trait-0.36.0//:async_trait
We take everything up to + excluding the first ., then take everything up to + excluding the last -, then strip @crates__ from the front.
It looks like a dumb hack (and it is), but it works. I've raised:
What is the goal of this PR?
assemble_crate
now supports procedural macro dependencies, and is more reliable at correctly detecting the crate names of all dependencies. In particular, crates with hyphens (such asasync-trait
) should no longer cause issues.What are the changes implemented in this PR?
Previously
assemble_crate
aggregated dependency info via only thedeps
attribute of arust_*
target. Now,proc_macro_deps
is traversed as well.Also, crate name detection has been reworked. Because
rules_rust
doesn't expose the original name of the crate downloaded from Cargo anywhere, we were unable to reliably get that crate name and put it intoCargo.toml
. Now, we use string parsing against the target's label. This works because the label is (e.g):We take everything up to + excluding the first
.
, then take everything up to + excluding the last-
, then strip@crates__
from the front.It looks like a dumb hack (and it is), but it works. I've raised: