Is there a way to unify cargo features between different
cargo build --package X invocations, so they don't have to rebuild dependencies?
I have a CI for a project with a lot of crates with various features, all in one cargo workspace. We're using Nix to build them all (
crane to be specific).
I have build for various packages which comes down to building with:
cargo build --package <pkga>
cargo build --package <pkgb>
crane allows me to have intermediate builds, including builds that contain only the dependencies of the project compiled.
So what I'd like to have is:
- build all project dependencies
- build pkga, reusing already compiled dependencies
- build pkgsa, reusing already compile depdencies
However when actually running it I've noticed that each build of a package recompiles the dependencies again.
I suspect this is due to a number of features in packages pkga and pkgb and packages they depend on. Depending which one I'm building, different sets will be enabled which causes cargo to rebuild things. (?)
Any ideas how would I avoid that?