build-system/gnu: Really ignore the return value of phases.
This is a followup to 04baa011e9.
* 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.
			
			
This commit is contained in:
		
							parent
							
								
									f8281090d4
								
							
						
					
					
						commit
						9621809ce8
					
				
					 1 changed files with 22 additions and 9 deletions
				
			
		| 
						 | 
					@ -887,14 +887,27 @@ in order.  Return #t if all the PHASES succeeded, #f otherwise."
 | 
				
			||||||
    (for-each (match-lambda
 | 
					    (for-each (match-lambda
 | 
				
			||||||
                ((name . proc)
 | 
					                ((name . proc)
 | 
				
			||||||
                 (let ((start (current-time time-monotonic)))
 | 
					                 (let ((start (current-time time-monotonic)))
 | 
				
			||||||
                   (format #t "starting phase `~a'~%" name)
 | 
					                   (define (end-of-phase success?)
 | 
				
			||||||
                   (let ((result (apply proc args))
 | 
					                     (let ((end (current-time time-monotonic)))
 | 
				
			||||||
                         (end    (current-time time-monotonic)))
 | 
					 | 
				
			||||||
                       (format #t "phase `~a' ~:[failed~;succeeded~] after ~,1f seconds~%"
 | 
					                       (format #t "phase `~a' ~:[failed~;succeeded~] after ~,1f seconds~%"
 | 
				
			||||||
                             name result
 | 
					                               name success?
 | 
				
			||||||
                               (elapsed-time end start))
 | 
					                               (elapsed-time end start))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                     ;; Dump the environment variables as a shell script, for handy debugging.
 | 
					                       ;; Dump the environment variables as a shell script,
 | 
				
			||||||
                     (system "export > $NIX_BUILD_TOP/environment-variables")
 | 
					                       ;; for handy debugging.
 | 
				
			||||||
                     result))))
 | 
					                       (system "export > $NIX_BUILD_TOP/environment-variables")))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                   (format #t "starting phase `~a'~%" name)
 | 
				
			||||||
 | 
					                   (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)))
 | 
					              phases)))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue