mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-16 14:54:29 +01:00
14d44173e4
buildRustPackage: support custom cargo profiles
53 lines
1.3 KiB
Bash
53 lines
1.3 KiB
Bash
declare -a cargoBuildFlags
|
|
|
|
cargoBuildHook() {
|
|
echo "Executing cargoBuildHook"
|
|
|
|
runHook preBuild
|
|
|
|
# Let stdenv handle stripping, for consistency and to not break
|
|
# separateDebugInfo.
|
|
export "CARGO_PROFILE_${cargoBuildType@U}_STRIP"=false
|
|
|
|
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
|
# ensure the output doesn't end up in the subdirectory
|
|
export CARGO_TARGET_DIR="$(pwd)/target"
|
|
|
|
pushd "${buildAndTestSubdir}"
|
|
fi
|
|
|
|
if [ "${cargoBuildType}" != "debug" ]; then
|
|
cargoBuildProfileFlag="--profile ${cargoBuildType}"
|
|
fi
|
|
|
|
if [ -n "${cargoBuildNoDefaultFeatures-}" ]; then
|
|
cargoBuildNoDefaultFeaturesFlag=--no-default-features
|
|
fi
|
|
|
|
if [ -n "${cargoBuildFeatures-}" ]; then
|
|
cargoBuildFeaturesFlag="--features=${cargoBuildFeatures// /,}"
|
|
fi
|
|
|
|
(
|
|
set -x
|
|
@setEnv@ cargo build -j $NIX_BUILD_CORES \
|
|
--target @rustHostPlatformSpec@ \
|
|
--frozen \
|
|
${cargoBuildProfileFlag} \
|
|
${cargoBuildNoDefaultFeaturesFlag} \
|
|
${cargoBuildFeaturesFlag} \
|
|
${cargoBuildFlags}
|
|
)
|
|
|
|
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
|
popd
|
|
fi
|
|
|
|
runHook postBuild
|
|
|
|
echo "Finished cargoBuildHook"
|
|
}
|
|
|
|
if [ -z "${dontCargoBuild-}" ] && [ -z "${buildPhase-}" ]; then
|
|
buildPhase=cargoBuildHook
|
|
fi
|