crane/lib/cargoLlvmCov.nix
figsoda 475de74fa2
feat: add cargoLlvmCov (#267)
* feat: add cargoLlvmCov
* cargoHelperFunctionsHook: prefer `--release` over `--profile release`
Some tools (e.g. cargo-llvm-cov) don't understand `--profile release` as
an alias for `--release`, so `cargoWithProfile` should prefer passing
`--release` when `$CARGO_PROFILE` == "release"

---------

Co-authored-by: Ivan Petkov <ivanppetkov@gmail.com>
2023-03-19 23:44:14 +00:00

32 lines
635 B
Nix

{ mkCargoDerivation
, cargo-llvm-cov
}:
{ cargoExtraArgs ? ""
, cargoLlvmCovCommand ? "test"
, cargoLlvmCovExtraArgs ? "--lcov --output-path $out"
, ...
}@origArgs:
let
args = builtins.removeAttrs origArgs [
"cargoExtraArgs"
"cargoLlvmCovCommand"
"cargoLlvmCovExtraArgs"
];
in
mkCargoDerivation (args // {
pnameSuffix = "-llvm-cov";
nativeBuildInputs = (args.nativeBuildInputs or [ ]) ++ [ cargo-llvm-cov ];
doInstallCargoArtifacts = false;
buildPhaseCargoCommand = ''
cargoWithProfile llvm-cov "${cargoLlvmCovCommand}" ${cargoExtraArgs} ${cargoLlvmCovExtraArgs}
'';
installPhaseCommand = "";
})