2021-03-09 03:18:52 +00:00
|
|
|
declare -a cargoBuildFlags
|
|
|
|
|
|
|
|
cargoBuildHook() {
|
|
|
|
echo "Executing cargoBuildHook"
|
|
|
|
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
|
|
|
pushd "${buildAndTestSubdir}"
|
|
|
|
fi
|
|
|
|
|
2021-03-19 17:17:44 +00:00
|
|
|
if [ "${cargoBuildType}" != "debug" ]; then
|
|
|
|
cargoBuildProfileFlag="--${cargoBuildType}"
|
|
|
|
fi
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
if [ -n "${cargoBuildNoDefaultFeatures-}" ]; then
|
|
|
|
cargoBuildNoDefaultFeaturesFlag=--no-default-features
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${cargoBuildFeatures-}" ]; then
|
|
|
|
cargoBuildFeaturesFlag="--features=${cargoBuildFeatures// /,}"
|
|
|
|
fi
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
(
|
|
|
|
set -x
|
|
|
|
env \
|
|
|
|
"CC_@rustBuildPlatform@=@ccForBuild@" \
|
|
|
|
"CXX_@rustBuildPlatform@=@cxxForBuild@" \
|
|
|
|
"CC_@rustTargetPlatform@=@ccForHost@" \
|
|
|
|
"CXX_@rustTargetPlatform@=@cxxForHost@" \
|
|
|
|
cargo build -j $NIX_BUILD_CORES \
|
|
|
|
--target @rustTargetPlatformSpec@ \
|
|
|
|
--frozen \
|
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
|