1 # shellcheck shell=bash disable=SC2154,SC2164
4 echo "Executing cargoBuildHook"
8 # Let stdenv handle stripping, for consistency and to not break
10 export "CARGO_PROFILE_${cargoBuildType@U}_STRIP"=false
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
17 pushd "${buildAndTestSubdir}"
21 "-j" "$NIX_BUILD_CORES"
22 "--target" "@rustHostPlatformSpec@"
26 if [ "${cargoBuildType}" != "debug" ]; then
27 flagsArray
+=("--profile" "${cargoBuildType}")
30 if [ -n "${cargoBuildNoDefaultFeatures-}" ]; then
31 flagsArray
+=("--no-default-features")
34 if [ -n "${cargoBuildFeatures-}" ]; then
35 flagsArray
+=("--features=$(concatStringsSep "," cargoBuildFeatures)")
38 concatTo flagsArray cargoBuildFlags
40 echoCmd
'cargoBuildHook flags' "${flagsArray[@]}"
41 @setEnv@ cargo build
"${flagsArray[@]}"
43 if [ -n "${buildAndTestSubdir-}" ]; then
49 echo "Finished cargoBuildHook"
52 if [ -z "${dontCargoBuild-}" ] && [ -z "${buildPhase-}" ]; then
53 buildPhase
=cargoBuildHook