From e640c9e6f3da88d575f719a013b7b9806060a240 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Sun, 1 Apr 2018 12:10:30 +0200 Subject: gexp: compiled-modules: Factorize build code. * guix/gexp.scm (compiled-modules)[build]: Factorize 'process-entry'. --- guix/gexp.scm | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'guix/gexp.scm') diff --git a/guix/gexp.scm b/guix/gexp.scm index b47965d9eb..612af624fe 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -1068,25 +1068,21 @@ (define build (define (regular? file) (not (member file '("." "..")))) + (define (process-entry entry output) + (if (file-is-directory? entry) + (let ((output (string-append output "/" (basename entry)))) + (mkdir-p output) + (process-directory entry output)) + (let* ((base (basename entry ".scm")) + (output (string-append output "/" base ".go"))) + (compile-file entry + #:output-file output + #:opts %auto-compilation-options)))) + (define (process-directory directory output) (let ((entries (map (cut string-append directory "/" <>) (scandir directory regular?)))) - (for-each (lambda (entry) - (if (file-is-directory? entry) - (let ((output (string-append output "/" - (basename entry)))) - (mkdir-p output) - (process-directory entry output)) - (let* ((base (string-drop-right - (basename entry) - 4)) ;.scm - (output (string-append output "/" base - ".go"))) - (compile-file entry - #:output-file output - #:opts - %auto-compilation-options)))) - entries))) + (for-each (cut process-entry <> output) entries))) (set! %load-path (cons (ungexp modules) %load-path)) (mkdir (ungexp output)) -- cgit v1.2.3