me
/
guix
Archived
1
0
Fork 0

gexp: compiled-modules: Factorize build code.

* guix/gexp.scm (compiled-modules)[build]: Factorize 'process-entry'.
master
Ludovic Courtès 2018-04-01 12:10:30 +02:00
parent 6422bde9b4
commit e640c9e6f3
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 12 additions and 16 deletions

View File

@ -1068,25 +1068,21 @@ they can refer to each other."
(define (regular? file) (define (regular? file)
(not (member 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) (define (process-directory directory output)
(let ((entries (map (cut string-append directory "/" <>) (let ((entries (map (cut string-append directory "/" <>)
(scandir directory regular?)))) (scandir directory regular?))))
(for-each (lambda (entry) (for-each (cut process-entry <> output) entries)))
(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)))
(set! %load-path (cons (ungexp modules) %load-path)) (set! %load-path (cons (ungexp modules) %load-path))
(mkdir (ungexp output)) (mkdir (ungexp output))