From 50b2ef28f72a824efc0dde96094133fc07a36433 Mon Sep 17 00:00:00 2001 From: Andreas Rammhold Date: Wed, 11 Dec 2019 22:27:12 +0100 Subject: buildRustCrate: move the color loggign & remove some runtime checks The expression is already long and confusing enough without the color stuff sprinkled in. Moving it to a dedicated file makes sense. I switched a bit of the color support code to pure Nix since there wasn't much point in doing that in bash while we can just do it in Nix. --- pkgs/build-support/rust/build-rust-crate/log.nix | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 pkgs/build-support/rust/build-rust-crate/log.nix (limited to 'pkgs/build-support/rust/build-rust-crate/log.nix') diff --git a/pkgs/build-support/rust/build-rust-crate/log.nix b/pkgs/build-support/rust/build-rust-crate/log.nix new file mode 100644 index 00000000000..25181c787e2 --- /dev/null +++ b/pkgs/build-support/rust/build-rust-crate/log.nix @@ -0,0 +1,33 @@ +{ lib }: +{ + echo_build_heading = colors: '' + echo_build_heading() { + start="" + end="" + ${lib.optionalString (colors == "always") '' + start="$(printf '\033[0;1;32m')" #set bold, and set green. + end="$(printf '\033[0m')" #returns to "normal" + ''} + if (( $# == 1 )); then + echo "$start""Building $1""$end" + else + echo "$start""Building $1 ($2)""$end" + fi + } + ''; + noisily = colors: verbose: '' + noisily() { + start="" + end="" + ${lib.optionalString (colors == "always") '' + start="$(printf '\033[0;1;32m')" #set bold, and set green. + end="$(printf '\033[0m')" #returns to "normal" + ''} + ${lib.optionalString verbose '' + echo -n "$start"Running "$end" + echo $@ + ''} + $@ + } + ''; +} -- cgit 1.4.1