I have a build script where I have access to a lot of information about another crate via cargo_metadata.
Now I'm looking for the way to find all invocations of a specific proc-macro
inside the another crate.
Theoretically, I can parse another crate's sources by myself but I prefer to avoid it in any way possible for the well known reasons :-)
Ideally, I'm looking for the crate which is used by the compiler already. Or at least the crate which somehow use compiler's output to collect that kind of information.
But any solution will be helpful!
There is how ideal solution may looks like from my code prospective:
use proc_macro::TokenStream;
use some_cool_crate::macros_lookup;
use some_cool_crate::Macros;
let path_to_another_crates_cargo_toml = "/path/to/another_crate/Cargo.toml";
let macros = Macros {
name: "my_macro",
crate: "macro_original_crate",
};
// The thing I'm looking for:
macros_lookup(
path_to_another_crates_cargo_toml,
¯os,
|attr: TokenStream, input: TokenStream,| {
// there I'll do some interesting stuff
},
);
P.S. Currently I obtain the information from custom section of Cargo.toml
's [package.metadata]
but it requires me to keep Cargo.toml
in sync with the sources.
P.P.S. The reason I'm doing all that "cool" stuff is broken Re-exporting C symbols for cdylib