mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-26 23:54:01 +00:00
4816a73bb5
--frozen is stricter than we need in Nixpkgs. If a Cargo.lock is slightly wrong, or (in my use case) if building a subproject that is not a member of the top-level workspace, but the correct Cargo.lock can be entirely resolved from the existing top-level Cargo.lock, it should be deterministic, and shouldn't cause any problems, to let cargo generate the new Cargo.lock. This should result in less need to bother upstreams about fixing their Cargo.lock files in cases where they could have been automatically fixed.
61 lines
1.5 KiB
Bash
61 lines
1.5 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
|
|
if [ -n "$__structuredAttrs" ]; then
|
|
OLDIFS="$IFS"
|
|
IFS=','; cargoBuildFeaturesFlag="--features=${cargoBuildFeatures[*]}"
|
|
IFS="$OLDIFS"
|
|
unset OLDIFS
|
|
else
|
|
cargoBuildFeaturesFlag="--features=${cargoBuildFeatures// /,}"
|
|
fi
|
|
fi
|
|
|
|
(
|
|
set -x
|
|
@setEnv@ cargo build -j $NIX_BUILD_CORES \
|
|
--target @rustHostPlatformSpec@ \
|
|
--offline \
|
|
${cargoBuildProfileFlag} \
|
|
${cargoBuildNoDefaultFeaturesFlag} \
|
|
${cargoBuildFeaturesFlag} \
|
|
${cargoBuildFlags}
|
|
)
|
|
|
|
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
|
popd
|
|
fi
|
|
|
|
runHook postBuild
|
|
|
|
echo "Finished cargoBuildHook"
|
|
}
|
|
|
|
if [ -z "${dontCargoBuild-}" ] && [ -z "${buildPhase-}" ]; then
|
|
buildPhase=cargoBuildHook
|
|
fi
|