-
Right now However, when used in CI, it seems like a waste of time to build the release mode. So here is the question - what would be the neatest way to parametrize the existing build ( |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
Easiest way? Set It's worth noting that cargo considers debug and release artifacts to be different, so if your CI doesn't build production/release builds your consumers may need to build it themselves (but you might not care about this). I'd also note that you should be careful not to mix debug It's also technically possible to build and cache both release and debug artifacts, but that will result in a lot more data being cached/copied around, so pick your poison # Build both debug and release artifacts, be careful with cache bloat!
let
src = ./whatever;
cargoArtifactsDebug = craneLib.buildDepsOnly {
inherit src;
CARGO_PROFILE = "dev";
};
cargoArtifactsReleaseAndDebug = craneLib.buildDepsOnly {
inherit src;
cargoArtifacts = cargoArtifactsDebug;
CARGO_PROFILE = "release";
};
in
{
myCrateRelease = craneLib.buildPackage {
inherit src;
cargoArtifacts = cargoArtifactsReleaseAndDebug;
CARGO_PROFILE = "release";
};
myCrateDebug = craneLib.buildPackage {
inherit src;
cargoArtifacts = cargoArtifactsReleaseAndDebug;
CARGO_PROFILE = "dev";
};
} |
Beta Was this translation helpful? Give feedback.
Easiest way? Set
CARGO_PROFILE = "dev";
in the derivation and all cargo invocations will effectively run ascargo --profile dev
(which is the default "debug" profile used by cargo)It's worth noting that cargo considers debug and release artifacts to be different, so if your CI doesn't build production/release builds your consumers may need to build it themselves (but you might not care about this).
I'd also note that you should be careful not to mix debug
cargoArtifacts
built with a derivation which expects to do a release build. Cargo will happily compile everything, but effectively you won't get any benefits of artifact caching.It's also technically possible to build and cache both re…