nixpkgs-suyu/pkgs/build-support/rust/hooks/cargo-build-hook.sh
Ana Hobden a84cb88c47 rustPlatform.buildRustPackage: support debug builds
Signed-off-by: Ana Hobden <operator@hoverbear.org>
2021-03-04 07:16:29 -08:00

39 lines
849 B
Bash

declare -a cargoBuildFlags
cargoBuildHook() {
echo "Executing cargoBuildHook"
runHook preBuild
if [ ! -z "${buildAndTestSubdir-}" ]; then
pushd "${buildAndTestSubdir}"
fi
if [ "${cargoBuildType}" != "debug" ]; then
cargoBuildProfileFlag="--${cargoBuildType}"
fi
(
set -x
env \
"CC_@rustBuildPlatform@=@ccForBuild@" \
"CXX_@rustBuildPlatform@=@cxxForBuild@" \
"CC_@rustTargetPlatform@=@ccForHost@" \
"CXX_@rustTargetPlatform@=@cxxForHost@" \
cargo build -j $NIX_BUILD_CORES \
--target @rustTargetPlatformSpec@ \
--frozen \
${cargoBuildProfileFlag} \
${cargoBuildFlags}
)
if [ ! -z "${buildAndTestSubdir-}" ]; then
popd
fi
runHook postBuild
echo "Finished cargoBuildHook"
}
buildPhase=cargoBuildHook