I’m looking to get the complete list of source (ie module and include*!) files used to build a particular target. At the moment, cargo metadata only includes the top-level source file.
rustc has the --emit deps-info option, and which cargo uses when it invokes rustc. But I couldn’t see a way to access that information (it wasn’t actually obvious to me that it uses it).
Is there some existing extension which provides this information? Or alternatively, would it make sense to extend the metadata json to include it? Or is there some fundamental reason why this wouldn’t work?
(Background: my goal is to write a tool which can take a Cargo.toml and generate build rules for a different build system, which needs all input files to be explicitly listed.)
You can’t do that in cargo metadata because you need to fully build code to get this information.
So the solution here is to run cargo build and fetch depinfo files manually from the target dir. There maybe a chance that passing —message-format=json to cargo build will output path to depinfo, but I am not sure about that.