[Top][All Lists]

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

03/03: gexp: 'compiled-modules' prints a line for each module.

From: Ludovic Courtès
Subject: 03/03: gexp: 'compiled-modules' prints a line for each module.
Date: Sun, 1 Apr 2018 06:36:46 -0400 (EDT)

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

commit d32922759bfeffa03ee189158ea00b1a0ddbe8c6
Author: Ludovic Courtès <address@hidden>
Date:   Sun Apr 1 12:33:28 2018 +0200

    gexp: 'compiled-modules' prints a line for each module.
    * guix/gexp.scm (compiled-modules)[build]: Add 'processed' parameter to
    'process-entry' and 'process-directory'.  Print a message before each
    'compile-file' call.
 guix/gexp.scm | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/guix/gexp.scm b/guix/gexp.scm
index 612af62..2deec25 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -1051,6 +1051,8 @@ last one is created from the given <scheme-file> object."
   "Return a derivation that builds a tree containing the `.go' files
 corresponding to MODULES.  All the MODULES are built in a context where
 they can refer to each other."
+  (define total (length modules))
   (mlet %store-monad ((modules (imported-modules modules
                                                  #:system system
                                                  #:guile guile
@@ -1062,32 +1064,42 @@ they can refer to each other."
          (primitive-load (ungexp %utils-module))  ;for 'mkdir-p'
          (use-modules (ice-9 ftw)
+                      (ice-9 format)
+                      (srfi srfi-1)
                       (srfi srfi-26)
                       (system base compile))
          (define (regular? file)
            (not (member file '("." ".."))))
-         (define (process-entry entry output)
+         (define (process-entry entry output processed)
            (if (file-is-directory? entry)
                (let ((output (string-append output "/" (basename entry))))
                  (mkdir-p output)
-                 (process-directory entry output))
+                 (process-directory entry output processed))
                (let* ((base   (basename entry ".scm"))
                       (output (string-append output "/" base ".go")))
+                 (format #t "address@hidden/address@hidden Compiling '~a'...~%"
+                         (+ 1 processed) (ungexp total) entry)
                  (compile-file entry
                                #:output-file output
-                               #:opts %auto-compilation-options))))
+                               #:opts %auto-compilation-options)
+                 (+ 1 processed))))
-         (define (process-directory directory output)
+         (define (process-directory directory output processed)
            (let ((entries (map (cut string-append directory "/" <>)
                                (scandir directory regular?))))
-             (for-each (cut process-entry <> output) entries)))
+             (fold (cut process-entry <> output <>)
+                   processed
+                   entries)))
+         (setvbuf (current-output-port)
+                  (cond-expand (guile-2.2 'line) (else _IOLBF)))
          (set! %load-path (cons (ungexp modules) %load-path))
          (mkdir (ungexp output))
          (chdir (ungexp modules))
-         (process-directory "." (ungexp output)))))
+         (process-directory "." (ungexp output) 0))))
     ;; TODO: Pass MODULES as an environment variable.
     (gexp->derivation name build

reply via email to

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