1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-28 08:31:59 +00:00
nixpkgs/pkgs/build-support/rust/hooks/cargo-build-hook.sh
2021-03-08 19:17:03 +01:00

42 lines
918 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"
}
if [ -z "${dontCargoBuild-}" ] && [ -z "${buildPhase-}" ]; then
buildPhase=cargoBuildHook
fi