bbqsrc/cargo-ndk

Only invoke cargo metadata for desired target(s)

Closed this issue · 2 comments

Unlike most other cargo tools, cargo metadata counter-intuitively defaults to including all targets. This means that with the current logic, cargo-ndk 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

let metadata = match MetadataCommand::new().exec() {

cargo-ndk 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!

Hey @jonhoo,

Actually planning on reworking the metadata handling and may entirely remove it in v3.

Done. :)