Hi Ricardo, Patch file is attached with changes.
I modified guix/scripts/build.scm /(parameterize ((current-build-output-port (if quiet?// // (%make-void-port "w")// // (current-error-port))))// / to by REPLACING this to use colored output /(parameterize ((current-build-output-port colorful-build-output-port))/ UI.scm had the necessary changes. I am getting the following error when building a package /In ice-9/boot-9.scm:// // 837:9 6 (catch _ _ #<procedure 7f6bc6a0c468 at guix/ui.scm:589?> ?)// // 837:9 5 (catch _ _ #<procedure 7f6bc6a0c480 at guix/ui.scm:697?> ?)// //In guix/scripts/build.scm:// // 781:24 4 (_)// //In guix/store.scm:// // 936:15 3 (_ #<build-daemon 256.97 919e60> _ _)// // 620:13 2 (process-stderr _ _)// //In unknown file:// // 1 (display "@ build-started /gnu/store/gxv20gis2i4xk8nmn?" ?)// // 0 (display "@ build-started /gnu/store/gxv20gis2i4xk8nmn?" ?)// // //ERROR: In procedure display:// //ERROR: In procedure display: Wrong type argument in position 2: #«parameter> 870600 proc: #<procedure 779340 at ice-9/boot-9.scm:1419:15 () | (x)»/
From 3b74ea60a13fef3141f4bedb52f9e8131aaec101 Mon Sep 17 00:00:00 2001 From: Sahithi Yarlagadda <s...@swecha.net> Date: Tue, 5 Jun 2018 00:08:32 +0530 Subject: [PATCH] guix: Add coloring soft port. * guix/ui.scm (handle-string): New procedures. (colorful-build-output-port): New variable. guix: Added colorful-build-output-port to build.scm instead of default --- guix/scripts/build.scm | 5 +---- guix/ui.scm | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 5 deletions(-) mode change 100644 => 100755 guix/scripts/build.scm mode change 100644 => 100755 guix/ui.scm diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm old mode 100644 new mode 100755 index 4dd4fbccd..be457443b --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -732,10 +732,7 @@ needed." (with-store store ;; Set the build options before we do anything else. (set-build-options-from-command-line store opts) - - (parameterize ((current-build-output-port (if quiet? - (%make-void-port "w") - (current-error-port)))) +(parameterize ((current-build-output-port colorful-build-output-port)) (let* ((mode (assoc-ref opts 'build-mode)) (drv (options->derivations store opts)) (urls (map (cut string-append <> "/log") diff --git a/guix/ui.scm b/guix/ui.scm old mode 100644 new mode 100755 index 80f1a4d77..7774cf78c --- a/guix/ui.scm +++ b/guix/ui.scm @@ -109,7 +109,7 @@ warning info guix-main - colorize-string)) + colorful-build-output-port)) ;;; Commentary: ;;; @@ -1631,4 +1631,44 @@ be reset such that subsequent output will not have any colors in effect." str (color 'RESET))) + +(define (handle-string str) + (let ((message (or (and=> (string-match "^(starting phase)(.*)" str) + (lambda (m) + (string-append + (colorize-string (match:substring m 1) '(BLUE)) + (colorize-string (match:substring m 2) '(GREEN))))) + + (and=> (string-match "^(phase) (.*) (succeeded after) (.*) (seconds)" str) + (lambda (m) + (string-append + (colorize-string (match:substring m 1) '(BLUE)) + (colorize-string (match:substring m 2) '(GREEN)) + (colorize-string (match:substring m 3) '(BLUE)) + (colorize-string (match:substring m 4) '(GREEN)) + (colorize-string (match:substring m 5) '(BLUE))))) + + (and=> (string-match "^(phase)(.*) (failed after) (.*) (seconds)" str) + (lambda (m) + (string-append + (colorize-string (match:substring m 1) '(RED)) + (colorize-string (match:substring m 2) '(GREEN)) + (colorize-string (match:substring m 3) '(RED)) + (colorize-string (match:substring m 4) '(GREEN)) + (colorize-string (match:substring m 5) '(RED))))) + + ;; Didnât match, so return unmodified string. + str))) + (display message (current-error-port)))) + +(define colorful-build-output-port + (make-soft-port + (vector + (lambda (c) (write c current-error-port)) + handle-string + (lambda () (display "." current-error-port)) + (lambda () (char-upcase (read-char))) + (lambda () (display "@" current-error-port))) + "rw")) + ;;; ui.scm ends here -- 2.11.0