Closed emthornber closed 10 months ago
This is the same as setting CARGO_TARGET_DIR
env var. cargo deb
should work with the env var.
However, I don't think this has any special relationship with cargo clean
. If you call cargo clean
without setting the same target dir (whether via env var or the arg), you're just making it irrelevant and act on a directory that probably doesn't exist anyway.
OTOH if you set different target dirs for different builds, then there's no reuse. If you set the same target dir for different targets, I'm not sure if there's any reuse happening either. It can't reuse any target-specific code of course. Maybe some host build dependencies that don't use build.rs
could be reused? (the build script can inspect the target and alter crate's behavior, so such crates aren't reusable across targets). But given that libc
has a build.rs
, there's very little that can be reused.
When building a package that is targeted at multiple architectures I set the --target-dir option to cargo to
target/<triple>
ortarget/localhost
. This avoids having to always rebuild everything after acargo clean
.cargo-deb doesn't accept
--target-dir
. Even if I build the rust executable first and then runcargo deb
I cannot indicate which target directory to use to avoid a rebuild.