Merge pull request #187975 from marius851000/rustRequiredFeatures

buildRustCrate: Do not compile binaries if all the requiredFeatures aren't enabled.

authored by John Ericson and committed by GitHub 6a0d3815 53f45437

+11 -1
+11 -1
pkgs/build-support/rust/build-rust-crate/build-crate.nix
··· 69 70 71 72 - ${lib.optionalString (lib.length crateBin > 0) (lib.concatMapStringsSep "\n" (bin: '' 73 mkdir -p target/bin 74 BIN_NAME='${bin.name or crateName}' 75 ${if !bin ? path then '' ··· 79 BIN_PATH='${bin.path}' 80 ''} 81 ${build_bin} "$BIN_NAME" "$BIN_PATH" 82 '') crateBin)} 83 84 ${lib.optionalString buildTests ''
··· 69 70 71 72 + ${lib.optionalString (lib.length crateBin > 0) (lib.concatMapStringsSep "\n" (bin: 73 + let 74 + haveRequiredFeature = if bin ? requiredFeatures then 75 + # Check that all element in requiredFeatures are also present in crateFeatures 76 + lib.intersectLists bin.requiredFeatures crateFeatures == bin.requiredFeatures 77 + else 78 + true; 79 + in 80 + if haveRequiredFeature then '' 81 mkdir -p target/bin 82 BIN_NAME='${bin.name or crateName}' 83 ${if !bin ? path then '' ··· 87 BIN_PATH='${bin.path}' 88 ''} 89 ${build_bin} "$BIN_NAME" "$BIN_PATH" 90 + '' else '' 91 + echo Binary ${bin.name or crateName} not compiled due to not having all of the required features -- ${lib.escapeShellArg (builtins.toJSON bin.requiredFeatures)} -- enabled. 92 '') crateBin)} 93 94 ${lib.optionalString buildTests ''