From e43223532c672febfa0f93a6fcb900dd2a7e6cd8 Mon Sep 17 00:00:00 2001 From: Harry Ho Date: Fri, 2 Jul 2021 15:57:04 +0800 Subject: [PATCH] mcu: fix cargo not building only the specified binary per job --- mcu/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mcu/default.nix b/mcu/default.nix index 388fb97..98c16a5 100644 --- a/mcu/default.nix +++ b/mcu/default.nix @@ -19,6 +19,12 @@ let }.nix" $out ''; # If binaryName is specified as an arg of buildStm32Firmware, + # then pass it as an argument for `cargo build`; otherwise, do not add such argument. + extraCargoBuildArgs = ( + (if (args ? extraCargoBuildArgs) then (args.extraCargoBuildArgs + " ") else "") + + (if (args ? binaryName) then ("--bin " + binaryName) else "") + ); + # If binaryName is specified, # then use it as the filename of the ELF generated from `cargo build`; # otherwise, use the `name` arg (i.e. the Rust package name) as the ELF filename. binaryName = if (args ? binaryName) then args.binaryName else name; @@ -34,7 +40,7 @@ let nativeBuildInputs = [ pkgs.llvm ] ++ extraNativeBuildInputs; buildPhase = '' export CARGO_HOME=$(mktemp -d cargo-home.XXX) - cargo build --release + cargo build --release ${extraCargoBuildArgs} ''; inherit checkPhase doCheck;