kornelski / cargo-deb

A cargo subcommand that generates Debian packages from information in Cargo.toml
https://lib.rs/cargo-deb
MIT License
404 stars 48 forks source link

Consider adding 'target-dir' option #106

Closed emthornber closed 10 months ago

emthornber commented 11 months ago

When building a package that is targeted at multiple architectures I set the --target-dir option to cargo to target/<triple> or target/localhost. This avoids having to always rebuild everything after a cargo clean.

cargo-deb doesn't accept --target-dir. Even if I build the rust executable first and then run cargo deb I cannot indicate which target directory to use to avoid a rebuild.

kornelski commented 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.