crate2nix icon indicating copy to clipboard operation
crate2nix copied to clipboard

Allow unifying features a.l.a. cargo build --all

Open Fuuzetsu opened this issue 3 years ago • 0 comments

Cargo has a questionable behaviour where

cargo build -pfoo
cargo build -pbar

does not give the same result as

cargo build -pfoo -pbar

In the first case, it will build all the dependencies of foo separately of all the dependencies of bar if they do have different features flags. In the second case, it will take the union of feature flags of the packages. It will only build the common dependency crates once.

In case of crate2nix, we are forced to always use the first method. This becomes quite a bit of a problem if you have many workspaces in your project. If you have a crate called foo and then have 10 different crates bar1, bar2, …, bar10 that depend on it and set some various set of features, you are going to be compiling foo 10 times as far as I understand. This may be desirable and is what cargo does if we invoke -pbarN separately for each package.

It'd be quite nice if there was a way to just have a single foo and have all the packages use it however. I'm not sure if that's easy or not to do but it could save a lot of time.

Relevant discussion on the Rust issue tracker https://github.com/rust-lang/cargo/issues/4463

Fuuzetsu avatar May 04 '21 04:05 Fuuzetsu