summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-10-26 09:07:37 +0200
committerLudovic Courtès <ludo@gnu.org>2012-10-26 09:07:37 +0200
commit20d83444dda3ccbb4e8bbff1d4cbfe429eb015f6 (patch)
tree49a64aa7861ca704904c18c9a93b58208002601f
parent450ccdc3aae6d1a0f1685de3bef4d962e18c3855 (diff)
downloadguix-20d83444dda3ccbb4e8bbff1d4cbfe429eb015f6.tar.gz
utils: Remove special `substitute*' syntax for lists of files.
* guix/build/utils.scm (substitute*): Remove special syntax for
  list-of-files; instead, check whether FILE is `list?' at run time.

* distro/packages/base.scm (gcc-4.7, %binutils-static): Adjust
  accordingly.
-rw-r--r--distro/packages/base.scm12
-rw-r--r--guix/build/utils.scm68
2 files changed, 44 insertions, 36 deletions
diff --git a/distro/packages/base.scm b/distro/packages/base.scm
index fd9f7055d2..4cf9f70a23 100644
--- a/distro/packages/base.scm
+++ b/distro/packages/base.scm
@@ -759,9 +759,9 @@ BFD (Binary File Descriptor) library, `gprof', `nm', `strip', etc.")
 
                  ;; Tell where to find libstdc++, libc, and `?crt*.o', except
                  ;; `crt{begin,end}.o', which come with GCC.
-                 (substitute* ("gcc/config/gnu-user.h"
-                               "gcc/config/i386/gnu-user.h"
-                               "gcc/config/i386/gnu-user64.h")
+                 (substitute* '("gcc/config/gnu-user.h"
+                                "gcc/config/i386/gnu-user.h"
+                                "gcc/config/i386/gnu-user64.h")
                    (("#define LIB_SPEC (.*)$" _ suffix)
                     (format #f "#define LIB_SPEC \"-L~a/lib -rpath=~a/lib \
 -rpath=~a/lib64 -rpath=~a/lib \" ~a~%"
@@ -2310,9 +2310,9 @@ store.")
                    ;; The `-all-static' libtool flag can only be passed
                    ;; after `configure', since configure tests don't use
                    ;; libtool, and only for executables built with libtool.
-                   (substitute* ("binutils/Makefile.in"
-                                 "gas/Makefile.in"
-                                 "ld/Makefile.in")
+                   (substitute* '("binutils/Makefile.in"
+                                  "gas/Makefile.in"
+                                  "ld/Makefile.in")
                      (("^LDFLAGS =(.*)$" line)
                       (string-append line
                                      "\nAM_LDFLAGS = -static -all-static\n"))))
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 26bdfff1db..8ae190f656 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -312,10 +312,10 @@ evaluated with each MATCH-VAR bound to the corresponding positional regexp
 sub-expression.  For example:
 
   (substitute* file
-               ((\"hello\")
-                \"good morning\\n\")
-               ((\"foo([a-z]+)bar(.*)$\" all letters end)
-                (string-append \"baz\" letter end)))
+     ((\"hello\")
+      \"good morning\\n\")
+     ((\"foo([a-z]+)bar(.*)$\" all letters end)
+      (string-append \"baz\" letter end)))
 
 Here, anytime a line of FILE contains \"hello\", it is replaced by \"good
 morning\".  Anytime a line of FILE matches the second regexp, ALL is bound to
@@ -323,33 +323,41 @@ the complete match, LETTERS is bound to the first sub-expression, and END is
 bound to the last one.
 
 When one of the MATCH-VAR is `_', no variable is bound to the corresponding
-match substring."
-    ((substitute* (file ...) clause ...)
-     (begin
-       (substitute* file clause ...)
-       ...))
+match substring.
+
+Alternatively, FILE may be a list of file names, in which case they are
+all subject to the substitutions."
     ((substitute* file ((regexp match-var ...) body ...) ...)
-     (substitute file
-                 (list (cons regexp
-                             (lambda (l m+)
-                               ;; Iterate over matches M+ and return the
-                               ;; modified line based on L.
-                               (let loop ((m* m+)   ; matches
-                                          (o  0)    ; offset in L
-                                          (r  '())) ; result
-                                 (match m*
-                                   (()
-                                    (let ((r (cons (substring l o) r)))
-                                      (string-concatenate-reverse r)))
-                                   ((m . rest)
-                                    (let-matches 0 m (match-var ...)
-                                      (loop rest
-                                            (match:end m)
-                                            (cons*
-                                             (begin body ...)
-                                             (substring l o (match:start m))
-                                             r))))))))
-                       ...)))))
+     (let ()
+       (define (substitute-one-file file-name)
+         (substitute
+          file-name
+          (list (cons regexp
+                      (lambda (l m+)
+                        ;; Iterate over matches M+ and return the
+                        ;; modified line based on L.
+                        (let loop ((m* m+)  ; matches
+                                   (o  0)   ; offset in L
+                                   (r  '())) ; result
+                          (match m*
+                            (()
+                             (let ((r (cons (substring l o) r)))
+                               (string-concatenate-reverse r)))
+                            ((m . rest)
+                             (let-matches 0 m (match-var ...)
+                               (loop rest
+                                     (match:end m)
+                                     (cons*
+                                      (begin body ...)
+                                      (substring l o (match:start m))
+                                      r))))))))
+                ...)))
+
+       (match file
+         ((files (... ...))
+          (for-each substitute-one-file files))
+         ((? string? f)
+          (substitute-one-file f)))))))
 
 
 ;;;