-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the ability to restrict what crates cargo fetch
downloads by target
#5216
Comments
I see that |
I'm thinking of picking this up, unless someone else is already working on it. I've spent a couple hours looking through the code which does the package/dependency filtering in |
cargo-fetch: add option to fetch for a target Teach cargo-fetch how to optionally fetch dependencies based on a target platform by specifying the target triple via `--target <TRIPLE>`. #5216
This seems to be done so issue can be closed. |
Indeed! |
I am building the crate only for the x86-64-unknown-linux-musl target. My crate depends on several crates that have optional, target-specific dependencies on the fuchsia-zircon crate and/or the winapi crate. Since I'm targetting Linux, I will never need those crates downloaded. However,
cargo fetch --locked
always downloads winapi and fuchsia-zircon, presumably just in case I decide to build for targets that need them. Downloading all the crates (currently 60, for a quite small code base) takes a non-trivial amount of time, so I'd like to avoid downloading any crates that won't be used for the targets I'm intending to build for. Thecargo fetch
happens in a Dockerfile and the Cargo.lock very frequently changes, causing the whole Dockerfile to be built from scratch.I propose that we add a
--target
or--targets
flag tocargo fetch
that works analogously to the same/similarly-named flag forcargo build
. In particular,cargo fetch
would only download dependencies that would be compiled bycargo build
for the given target(s), and it would avoid downloading the dependencies that wouldn't be compiled bycargo build
.The text was updated successfully, but these errors were encountered: