guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

05/05: build-system/gnu: Really ignore the return value of phases.


From: guix-commits
Subject: 05/05: build-system/gnu: Really ignore the return value of phases.
Date: Fri, 15 Jan 2021 08:07:02 -0500 (EST)

civodul pushed a commit to branch core-updates
in repository guix.

commit 9621809ce8d984fff6421cb55fc851a24954be06
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Jan 15 14:01:51 2021 +0100

    build-system/gnu: Really ignore the return value of phases.
    
    This is a followup to 04baa011e9122205009d6d5f15b8162bf6f3fb8a.
    
    * guix/build/gnu-build-system.scm (gnu-build): Really ignore the return
    value of PROC.  Wrap PROC call in 'with-throw-handler'.  Add
    'end-of-phase' procedure and use it.
---
 guix/build/gnu-build-system.scm | 31 ++++++++++++++++++++++---------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/guix/build/gnu-build-system.scm b/guix/build/gnu-build-system.scm
index e556457..f8e8a46 100644
--- a/guix/build/gnu-build-system.scm
+++ b/guix/build/gnu-build-system.scm
@@ -887,14 +887,27 @@ in order.  Return #t if all the PHASES succeeded, #f 
otherwise."
     (for-each (match-lambda
                 ((name . proc)
                  (let ((start (current-time time-monotonic)))
+                   (define (end-of-phase success?)
+                     (let ((end (current-time time-monotonic)))
+                       (format #t "phase `~a' ~:[failed~;succeeded~] after 
~,1f seconds~%"
+                               name success?
+                               (elapsed-time end start))
+
+                       ;; Dump the environment variables as a shell script,
+                       ;; for handy debugging.
+                       (system "export > 
$NIX_BUILD_TOP/environment-variables")))
+
                    (format #t "starting phase `~a'~%" name)
-                   (let ((result (apply proc args))
-                         (end    (current-time time-monotonic)))
-                     (format #t "phase `~a' ~:[failed~;succeeded~] after ~,1f 
seconds~%"
-                             name result
-                             (elapsed-time end start))
-
-                     ;; Dump the environment variables as a shell script, for 
handy debugging.
-                     (system "export > $NIX_BUILD_TOP/environment-variables")
-                     result))))
+                   (with-throw-handler #t
+                     (lambda ()
+                       (apply proc args)
+                       (end-of-phase #t))
+                     (lambda args
+                       ;; This handler executes before the stack is unwound.
+                       ;; The exception is automatically re-thrown from here,
+                       ;; and we should get a proper backtrace.
+                       (format (current-error-port)
+                               "error: in phase '~a': uncaught exception:
+~{~s ~}~%" name args)
+                       (end-of-phase #f))))))
               phases)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]