Only invoke cargo metadata for desired targets
mschlaipfer opened this issue · comments
Copying from a similar issue: bbqsrc/cargo-ndk#83
Unlike most other cargo tools, cargo metadata
counter-intuitively defaults to including all targets. This means that with the current logic, cargo-mutants
ends up processing (and thus downloading dependencies for) all targets even though the user has specifically called out the targets they want to build for. Specifically, in the MetadataCommand
invocation here
cargo-mutants/src/workspace.rs
Line 115 in 8898c07
cargo-mutants
should probably always specify --filter-platform
to each of the specified targets via MetadataCommand::other_options
. Unfortunately --filter-platform
only takes a single target triple, so you'd have to run metadata once per platform, but that's probably what you'd want to do anyway, since the dependency closure can vary between platforms.
Alternatively, if you aren't using any of the dependency metadata info, and are just invoking cargo metadata
in order to get information about the workspace, you can call MetadataCommand::no_deps
, which also makes the cargo metadata
invocation a fair bit faster!
Great idea, thanks @mschlaipfer and @jonhoo!
I had noticed that sometimes there was a perceptible pause while cargo updated dependencies, and it doesn't need that information at all. Sounds like no_deps
will work.