From a84cb88c47995042995d334f497514b20da19312 Mon Sep 17 00:00:00 2001 From: Ana Hobden Date: Wed, 3 Mar 2021 10:09:04 -0800 Subject: [PATCH] rustPlatform.buildRustPackage: support debug builds Signed-off-by: Ana Hobden --- pkgs/build-support/rust/hooks/cargo-build-hook.sh | 6 +++++- pkgs/build-support/rust/hooks/cargo-check-hook.sh | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/rust/hooks/cargo-build-hook.sh b/pkgs/build-support/rust/hooks/cargo-build-hook.sh index 54f4512d67ca..6760277c2941 100644 --- a/pkgs/build-support/rust/hooks/cargo-build-hook.sh +++ b/pkgs/build-support/rust/hooks/cargo-build-hook.sh @@ -9,6 +9,10 @@ cargoBuildHook() { pushd "${buildAndTestSubdir}" fi + if [ "${cargoBuildType}" != "debug" ]; then + cargoBuildProfileFlag="--${cargoBuildType}" + fi + ( set -x env \ @@ -19,7 +23,7 @@ cargoBuildHook() { cargo build -j $NIX_BUILD_CORES \ --target @rustTargetPlatformSpec@ \ --frozen \ - --${cargoBuildType} \ + ${cargoBuildProfileFlag} \ ${cargoBuildFlags} ) diff --git a/pkgs/build-support/rust/hooks/cargo-check-hook.sh b/pkgs/build-support/rust/hooks/cargo-check-hook.sh index bc913c6ab074..e4c906f873c4 100644 --- a/pkgs/build-support/rust/hooks/cargo-check-hook.sh +++ b/pkgs/build-support/rust/hooks/cargo-check-hook.sh @@ -16,7 +16,11 @@ cargoCheckHook() { threads=1 fi - argstr="--${cargoCheckType} --target @rustTargetPlatformSpec@ --frozen ${cargoTestFlags}"; + if [ "${cargoBuildType}" != "debug" ]; then + cargoBuildProfileFlag="--${cargoBuildType}" + fi + + argstr="${cargoBuildProfileFlag} --target @rustTargetPlatformSpec@ --frozen ${cargoTestFlags}"; ( set -x