aboutsummaryrefslogtreecommitdiff
path: root/guix/build/compile.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/build/compile.scm')
-rw-r--r--guix/build/compile.scm32
1 files changed, 24 insertions, 8 deletions
diff --git a/guix/build/compile.scm b/guix/build/compile.scm
index c8fe273f7e..c127456fd0 100644
--- a/guix/build/compile.scm
+++ b/guix/build/compile.scm
@@ -18,6 +18,7 @@
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
(define-module (guix build compile)
+ #:use-module (srfi srfi-1)
#:use-module (ice-9 match)
#:use-module (ice-9 format)
#:use-module (ice-9 threads)
@@ -58,13 +59,23 @@
((kw _ rest ...)
(loop rest `(#f ,kw ,@result))))))
+(define (supported-warning-type? type)
+ "Return true if TYPE, a symbol, denotes a supported warning type."
+ (find (lambda (warning-type)
+ (eq? type (warning-type-name warning-type)))
+ %warning-types))
+
(define %warnings
;; FIXME: 'format' is missing because it reports "non-literal format
;; strings" due to the fact that we use 'G_' instead of '_'. We'll need
;; help from Guile to solve this.
- '(unsupported-warning unbound-variable arity-mismatch
- macro-use-before-definition ;new in 2.2
- shadowed-toplevel)) ;new in 2.2.5
+ (let ((optional (lambda (type)
+ (if (supported-warning-type? type)
+ (list type)
+ '()))))
+ `(unbound-variable arity-mismatch
+ macro-use-before-definition ;new in 2.2
+ ,@(optional 'shadowed-toplevel)))) ;new in 2.2.5
(define (optimization-options file)
"Return the default set of optimizations options for FILE."
@@ -118,8 +129,9 @@ front."
(lambda ()
(set! path initial-value)))))
-(define (call/exit-on-exception thunk)
- "Evaluate THUNK and exit right away if an exception is thrown."
+(define (call/exit-on-exception file thunk)
+ "Evaluate THUNK and exit right away if an exception is thrown. Report FILE
+as the file that was being compiled when the exception was thrown."
(catch #t
thunk
(const #f)
@@ -130,15 +142,18 @@ front."
(stack (make-stack #t))
(depth (stack-length stack))
(frame (and (> depth 1) (stack-ref stack 1))))
+ (newline port)
+ (format port "error: failed to compile '~a':~%~%" file)
(false-if-exception (display-backtrace stack port))
(print-exception port frame key args)))
;; Don't go any further.
(primitive-exit 1))))
-(define-syntax-rule (exit-on-exception exp ...)
- "Evaluate EXP and exit if an exception is thrown."
- (call/exit-on-exception (lambda () exp ...)))
+(define-syntax-rule (exit-on-exception file exp ...)
+ "Evaluate EXP and exit if an exception is thrown. Report FILE as the faulty
+file when an exception is thrown."
+ (call/exit-on-exception file (lambda () exp ...)))
(define* (compile-files source-directory build-directory files
#:key
@@ -162,6 +177,7 @@ files are for HOST, a GNU triplet such as \"x86_64-linux-gnu\"."
;; Exit as soon as something goes wrong.
(exit-on-exception
+ file
(with-target host
(lambda ()
(let ((relative (relative-file source-directory file)))