From 578dfbe07bcd1bdef9129c6ce8529332a0abcba6 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Mon, 17 Jul 2017 23:21:55 +0200 Subject: gexp: 'ungexp-splicing' properly accounts for nested native inputs. Previously, (gexp-native-inputs #~#$@(list #~#+foo)) would return '(). This is a followup to 5b14a7902c58d9fb7923f9e16871f549fbe59b6e. * guix/gexp.scm (gexp-inputs)[add-reference-inputs]: In the list case, remove 'if' around 'fold-right'. In 'map' lambda, always inherit N?. * tests/gexp.scm ("gexp list splicing + ungexp-splicing"): New test. --- guix/gexp.scm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'guix/gexp.scm') diff --git a/guix/gexp.scm b/guix/gexp.scm index d9c4cb461e..2094c495d6 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -706,15 +706,17 @@ references; otherwise, return only non-native references." (cons `(,thing ,output) result) result)) (($ (lst ...) output n?) - (if (eqv? native? n?) - (fold-right add-reference-inputs result - ;; XXX: For now, automatically convert LST to a list of - ;; gexp-inputs. - (map (match-lambda - ((? gexp-input? x) x) - (x (%gexp-input x "out" (or n? native?)))) - lst)) - result)) + (fold-right add-reference-inputs result + ;; XXX: For now, automatically convert LST to a list of + ;; gexp-inputs. Inherit N?. + (map (match-lambda + ((? gexp-input? x) + (%gexp-input (gexp-input-thing x) + (gexp-input-output x) + n?)) + (x + (%gexp-input x "out" n?))) + lst))) (_ ;; Ignore references to other kinds of objects. result))) -- cgit v1.2.3 From 302d46e63f406f0f8acb024557498deaef2d4255 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 20 Jul 2017 15:48:09 +0200 Subject: gexp: Slightly improve error reporting for 'local-file'. Reported by Ricardo Wurmus. * guix/gexp.scm (local-file): Define using 'syntax-case' instead of 'syntax-rules'. Explicitly handle the zero-argument case and the use-as-an-identifier case. --- guix/gexp.scm | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'guix/gexp.scm') diff --git a/guix/gexp.scm b/guix/gexp.scm index 2094c495d6..2622c5cb62 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -269,8 +269,9 @@ vicinity of DIRECTORY." (string-append directory "/" file)) (else file)))) -(define-syntax-rule (local-file file rest ...) - "Return an object representing local file FILE to add to the store; this +(define-syntax local-file + (lambda (s) + "Return an object representing local file FILE to add to the store; this object can be used in a gexp. If FILE is a relative file name, it is looked up relative to the source file where this form appears. FILE will be added to the store under NAME--by default the base name of FILE. @@ -283,10 +284,23 @@ When RECURSIVE? is true, call (SELECT? FILE STAT) for each directory entry, where FILE is the entry's absolute file name and STAT is the result of 'lstat'; exclude entries for which SELECT? does not return true. -This is the declarative counterpart of the 'interned-file' monadic procedure." - (%local-file file - (delay (absolute-file-name file (current-source-directory))) - rest ...)) +This is the declarative counterpart of the 'interned-file' monadic procedure. +It is implemented as a macro to capture the current source directory where it +appears." + (syntax-case s () + ((_ file rest ...) + #'(%local-file file + (delay (absolute-file-name file (current-source-directory))) + rest ...)) + ((_) + #'(syntax-error "missing file name")) + (id + (identifier? #'id) + ;; XXX: We could return #'(lambda (file . rest) ...). However, + ;; (syntax-source #'id) is #f so (current-source-directory) would not + ;; work. Thus, simply forbid this form. + #'(syntax-error + "'local-file' is a macro and cannot be used like this"))))) (define (local-file-absolute-file-name file) "Return the absolute file name for FILE, a instance. A -- cgit v1.2.3