lol
1declare -a cargoBuildFlags
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 [ ! -z "${buildAndTestSubdir-}" ]; then
13 # ensure the output doesn't end up in the subdirectory
14 export CARGO_TARGET_DIR="$(pwd)/target"
15
16 pushd "${buildAndTestSubdir}"
17 fi
18
19 if [ "${cargoBuildType}" != "debug" ]; then
20 cargoBuildProfileFlag="--profile ${cargoBuildType}"
21 fi
22
23 if [ -n "${cargoBuildNoDefaultFeatures-}" ]; then
24 cargoBuildNoDefaultFeaturesFlag=--no-default-features
25 fi
26
27 if [ -n "${cargoBuildFeatures-}" ]; then
28 cargoBuildFeaturesFlag="--features=${cargoBuildFeatures// /,}"
29 fi
30
31 (
32 set -x
33 @setEnv@ cargo build -j $NIX_BUILD_CORES \
34 --target @rustHostPlatformSpec@ \
35 --frozen \
36 ${cargoBuildProfileFlag} \
37 ${cargoBuildNoDefaultFeaturesFlag} \
38 ${cargoBuildFeaturesFlag} \
39 ${cargoBuildFlags}
40 )
41
42 if [ ! -z "${buildAndTestSubdir-}" ]; then
43 popd
44 fi
45
46 runHook postBuild
47
48 echo "Finished cargoBuildHook"
49}
50
51if [ -z "${dontCargoBuild-}" ] && [ -z "${buildPhase-}" ]; then
52 buildPhase=cargoBuildHook
53fi