2021-02-15 12:08:06 +01:00
|
|
|
declare -a cargoBuildFlags
|
|
|
|
|
2021-02-11 17:32:47 +01:00
|
|
|
cargoBuildHook() {
|
|
|
|
echo "Executing cargoBuildHook"
|
|
|
|
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
|
|
|
pushd "${buildAndTestSubdir}"
|
|
|
|
fi
|
|
|
|
|
2021-03-03 19:09:04 +01:00
|
|
|
if [ "${cargoBuildType}" != "debug" ]; then
|
|
|
|
cargoBuildProfileFlag="--${cargoBuildType}"
|
|
|
|
fi
|
|
|
|
|
2021-02-11 17:32:47 +01: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-03 19:09:04 +01:00
|
|
|
${cargoBuildProfileFlag} \
|
2021-02-11 17:32:47 +01:00
|
|
|
${cargoBuildFlags}
|
|
|
|
)
|
|
|
|
|
|
|
|
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2021-02-15 06:54:18 +01:00
|
|
|
runHook postBuild
|
|
|
|
|
2021-02-11 17:32:47 +01:00
|
|
|
echo "Finished cargoBuildHook"
|
|
|
|
}
|
|
|
|
|
2021-03-01 02:18:12 +01:00
|
|
|
if [ -z "${dontCargoBuild-}" ] && [ -z "${buildPhase-}" ]; then
|
|
|
|
buildPhase=cargoBuildHook
|
|
|
|
fi
|