nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 54 lines 1.3 kB view raw
1# shellcheck shell=bash disable=SC2154,SC2164 2 3cargoBuildHook() { 4 echo "Executing cargoBuildHook" 5 6 runHook preBuild 7 8 # Let stdenv handle stripping, for consistency and to not break 9 # separateDebugInfo. 10 export "CARGO_PROFILE_${cargoBuildType@U}_STRIP"=false 11 12 if [ -n "${buildAndTestSubdir-}" ]; then 13 # ensure the output doesn't end up in the subdirectory 14 CARGO_TARGET_DIR="$(pwd)/target" 15 export CARGO_TARGET_DIR 16 17 pushd "${buildAndTestSubdir}" 18 fi 19 20 local flagsArray=( 21 "-j" "$NIX_BUILD_CORES" 22 "--target" "@rustcTargetSpec@" 23 "--offline" 24 ) 25 26 if [ "${cargoBuildType}" != "debug" ]; then 27 flagsArray+=("--profile" "${cargoBuildType}") 28 fi 29 30 if [ -n "${cargoBuildNoDefaultFeatures-}" ]; then 31 flagsArray+=("--no-default-features") 32 fi 33 34 if [ -n "${cargoBuildFeatures-}" ]; then 35 flagsArray+=("--features=$(concatStringsSep "," cargoBuildFeatures)") 36 fi 37 38 concatTo flagsArray cargoBuildFlags 39 40 echoCmd 'cargoBuildHook flags' "${flagsArray[@]}" 41 @setEnv@ cargo build "${flagsArray[@]}" 42 43 if [ -n "${buildAndTestSubdir-}" ]; then 44 popd 45 fi 46 47 runHook postBuild 48 49 echo "Finished cargoBuildHook" 50} 51 52if [ -z "${dontCargoBuild-}" ] && [ -z "${buildPhase-}" ]; then 53 buildPhase=cargoBuildHook 54fi