2021-03-09 03:18:52 +00:00
|
|
|
declare -a cargoBuildFlags
|
|
|
|
|
|
|
|
cargoBuildHook() {
|
|
|
|
echo "Executing cargoBuildHook"
|
|
|
|
|
|
|
|
runHook preBuild
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
# Let stdenv handle stripping, for consistency and to not break
|
|
|
|
# separateDebugInfo.
|
|
|
|
export "CARGO_PROFILE_${cargoBuildType@U}_STRIP"=false
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
2022-01-26 04:04:25 +00:00
|
|
|
# ensure the output doesn't end up in the subdirectory
|
|
|
|
export CARGO_TARGET_DIR="$(pwd)/target"
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
pushd "${buildAndTestSubdir}"
|
|
|
|
fi
|
|
|
|
|
2021-03-19 17:17:44 +00:00
|
|
|
if [ "${cargoBuildType}" != "debug" ]; then
|
2023-11-16 04:20:00 +00:00
|
|
|
cargoBuildProfileFlag="--profile ${cargoBuildType}"
|
2021-03-19 17:17:44 +00:00
|
|
|
fi
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
if [ -n "${cargoBuildNoDefaultFeatures-}" ]; then
|
|
|
|
cargoBuildNoDefaultFeaturesFlag=--no-default-features
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${cargoBuildFeatures-}" ]; then
|
2024-05-15 15:35:15 +00:00
|
|
|
if [ -n "$__structuredAttrs" ]; then
|
|
|
|
OLDIFS="$IFS"
|
|
|
|
IFS=','; cargoBuildFeaturesFlag="--features=${cargoBuildFeatures[*]}"
|
|
|
|
IFS="$OLDIFS"
|
|
|
|
unset OLDIFS
|
|
|
|
else
|
|
|
|
cargoBuildFeaturesFlag="--features=${cargoBuildFeatures// /,}"
|
|
|
|
fi
|
2021-12-06 16:07:01 +00:00
|
|
|
fi
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
(
|
|
|
|
set -x
|
2023-11-16 04:20:00 +00:00
|
|
|
@setEnv@ cargo build -j $NIX_BUILD_CORES \
|
|
|
|
--target @rustHostPlatformSpec@ \
|
2024-06-20 14:57:18 +00:00
|
|
|
--offline \
|
2021-03-19 17:17:44 +00:00
|
|
|
${cargoBuildProfileFlag} \
|
2021-12-06 16:07:01 +00:00
|
|
|
${cargoBuildNoDefaultFeaturesFlag} \
|
|
|
|
${cargoBuildFeaturesFlag} \
|
2021-03-09 03:18:52 +00:00
|
|
|
${cargoBuildFlags}
|
|
|
|
)
|
|
|
|
|
|
|
|
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
|
|
|
|
echo "Finished cargoBuildHook"
|
|
|
|
}
|
|
|
|
|
2021-03-19 17:17:44 +00:00
|
|
|
if [ -z "${dontCargoBuild-}" ] && [ -z "${buildPhase-}" ]; then
|
|
|
|
buildPhase=cargoBuildHook
|
|
|
|
fi
|