cargo-watch icon indicating copy to clipboard operation
cargo-watch copied to clipboard

`find_local_deps` should filter to the host platform when calling `cargo metadata`

Open alex-pinkus opened this issue 1 year ago • 1 comments

Unlike most other cargo tools, cargo metadata counter-intuitively defaults to including all targets. This means that currently, cargo-watch will process (and thus download metadata for) targets other than the one being used for the build -- see find_local_deps:

https://github.com/watchexec/cargo-watch/blob/30723ce1ffb3f9ba327a18265f2ff35338a0415a/src/options.rs#L195-L198

When running cargo watch without a custom command, cargo-check documentation makes clear that this is checking for the host architecture. This means that as long as the user doesn't specify a custom command, cargo watch can specify --filter-platform via MetadataCommand::other_options and avoid unnecessary processing.

alex-pinkus avatar Jul 19 '24 00:07 alex-pinkus

Huh, good to know, thanks!

A PR would be appreciated, otherwise I'll get to it next round of updates.

passcod avatar Jul 19 '24 02:07 passcod