2021-02-15 11:08:06 +00:00
|
|
|
declare -a cargoBuildFlags
|
|
|
|
|
2021-02-11 16:32:47 +00:00
|
|
|
cargoBuildHook() {
|
|
|
|
echo "Executing cargoBuildHook"
|
|
|
|
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
2021-12-26 08:02:26 +00:00
|
|
|
# ensure the output doesn't end up in the subdirectory
|
|
|
|
export CARGO_TARGET_DIR="$(pwd)/target"
|
|
|
|
|
2021-02-11 16:32:47 +00:00
|
|
|
pushd "${buildAndTestSubdir}"
|
|
|
|
fi
|
|
|
|
|
2021-03-03 18:09:04 +00:00
|
|
|
if [ "${cargoBuildType}" != "debug" ]; then
|
|
|
|
cargoBuildProfileFlag="--${cargoBuildType}"
|
|
|
|
fi
|
|
|
|
|
2021-10-27 03:41:37 +01:00
|
|
|
if [ -n "${cargoBuildNoDefaultFeatures-}" ]; then
|
|
|
|
cargoBuildNoDefaultFeaturesFlag=--no-default-features
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -n "${cargoBuildFeatures-}" ]; then
|
|
|
|
cargoBuildFeaturesFlag="--features=${cargoBuildFeatures// /,}"
|
|
|
|
fi
|
|
|
|
|
2021-02-11 16:32:47 +00: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 18:09:04 +00:00
|
|
|
${cargoBuildProfileFlag} \
|
2021-10-27 03:41:37 +01:00
|
|
|
${cargoBuildNoDefaultFeaturesFlag} \
|
|
|
|
${cargoBuildFeaturesFlag} \
|
2021-02-11 16:32:47 +00:00
|
|
|
${cargoBuildFlags}
|
|
|
|
)
|
|
|
|
|
|
|
|
if [ ! -z "${buildAndTestSubdir-}" ]; then
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2021-02-15 05:54:18 +00:00
|
|
|
runHook postBuild
|
|
|
|
|
2021-02-11 16:32:47 +00:00
|
|
|
echo "Finished cargoBuildHook"
|
|
|
|
}
|
|
|
|
|
2021-03-01 01:18:12 +00:00
|
|
|
if [ -z "${dontCargoBuild-}" ] && [ -z "${buildPhase-}" ]; then
|
|
|
|
buildPhase=cargoBuildHook
|
|
|
|
fi
|