rustPlatform: add support for features

figsoda 5a08a288 b6a580b9

+32 -1
+12
pkgs/build-support/rust/default.nix
··· 36 36 , cargoLock ? null 37 37 , cargoVendorDir ? null 38 38 , checkType ? buildType 39 + , buildNoDefaultFeatures ? false 40 + , checkNoDefaultFeatures ? buildNoDefaultFeatures 41 + , buildFeatures ? [ ] 42 + , checkFeatures ? buildFeatures 39 43 , depsExtraArgs ? {} 40 44 41 45 # Toggles whether a custom sysroot is created when the target is a .json file. ··· 102 106 cargoBuildType = buildType; 103 107 104 108 cargoCheckType = checkType; 109 + 110 + cargoBuildNoDefaultFeatures = buildNoDefaultFeatures; 111 + 112 + cargoCheckNoDefaultFeatures = checkNoDefaultFeatures; 113 + 114 + cargoBuildFeatures = buildFeatures; 115 + 116 + cargoCheckFeatures = checkFeatures; 105 117 106 118 patchRegistryDeps = ./patch-registry-deps; 107 119
+10
pkgs/build-support/rust/hooks/cargo-build-hook.sh
··· 13 13 cargoBuildProfileFlag="--${cargoBuildType}" 14 14 fi 15 15 16 + if [ -n "${cargoBuildNoDefaultFeatures-}" ]; then 17 + cargoBuildNoDefaultFeaturesFlag=--no-default-features 18 + fi 19 + 20 + if [ -n "${cargoBuildFeatures-}" ]; then 21 + cargoBuildFeaturesFlag="--features=${cargoBuildFeatures// /,}" 22 + fi 23 + 16 24 ( 17 25 set -x 18 26 env \ ··· 24 32 --target @rustTargetPlatformSpec@ \ 25 33 --frozen \ 26 34 ${cargoBuildProfileFlag} \ 35 + ${cargoBuildNoDefaultFeaturesFlag} \ 36 + ${cargoBuildFeaturesFlag} \ 27 37 ${cargoBuildFlags} 28 38 ) 29 39
+10 -1
pkgs/build-support/rust/hooks/cargo-check-hook.sh
··· 20 20 cargoCheckProfileFlag="--${cargoCheckType}" 21 21 fi 22 22 23 - argstr="${cargoCheckProfileFlag} --target @rustTargetPlatformSpec@ --frozen ${cargoTestFlags}"; 23 + if [ -n "${cargoCheckNoDefaultFeatures-}" ]; then 24 + cargoCheckNoDefaultFeaturesFlag=--no-default-features 25 + fi 26 + 27 + if [ -n "${cargoCheckFeatures-}" ]; then 28 + cargoCheckFeaturesFlag="--features=${cargoCheckFeatures// /,}" 29 + fi 30 + 31 + argstr="${cargoCheckProfileFlag} ${cargoCheckNoDefaultFeaturesFlag} ${cargoCheckFeaturesFlag} 32 + --target @rustTargetPlatformSpec@ --frozen ${cargoTestFlags}" 24 33 25 34 ( 26 35 set -x