guix-commits
[Top][All Lists]
Advanced

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

02/12: gexp: #:references-graphs accepts and honors <gexp-input> records


From: guix-commits
Subject: 02/12: gexp: #:references-graphs accepts and honors <gexp-input> records.
Date: Thu, 21 Dec 2023 18:36:52 -0500 (EST)

civodul pushed a commit to branch master
in repository guix.

commit 11a454f9dae84cc00b977d164dae764454ecb11d
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Nov 13 17:43:29 2023 +0100

    gexp: #:references-graphs accepts and honors <gexp-input> records.
    
    * guix/gexp.scm (lower-reference-graphs)[tuple->gexp-input]: Add
    ‘gexp-input?’ case.
    (gexp->derivation): Update docstring.
    * doc/guix.texi (G-Expressions): Adjust accordingly.
    * tests/gexp.scm ("references-file, non-default output"): New test.
    
    Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
    Change-Id: I595cb75da0867ab8ab44552887dc06ed1d23315e
---
 doc/guix.texi  |  7 +++----
 guix/gexp.scm  | 12 ++++++++----
 tests/gexp.scm | 30 ++++++++++++++++++++++++++++++
 3 files changed, 41 insertions(+), 8 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index a760d627eb..f869a6bae4 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12314,10 +12314,9 @@ When @var{references-graphs} is true, it must be a 
list of tuples of one of the
 following forms:
 
 @example
-(@var{file-name} @var{package})
-(@var{file-name} @var{package} @var{output})
-(@var{file-name} @var{derivation})
-(@var{file-name} @var{derivation} @var{output})
+(@var{file-name} @var{obj})
+(@var{file-name} @var{obj} @var{output})
+(@var{file-name} @var{gexp-input})
 (@var{file-name} @var{store-item})
 @end example
 
diff --git a/guix/gexp.scm b/guix/gexp.scm
index a7f4256d24..29819878fa 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -934,6 +934,11 @@ When TARGET is true, use it as the cross-compilation 
target triplet."
 corresponding <derivation-input> or store item."
   (define tuple->gexp-input
     (match-lambda
+      (((? gexp-input? input))
+       ;; This case lets users specify the output of interest more
+       ;; conveniently, for instance by passing (gexp-input hwloc "lib") to
+       ;; the 'references-file' procedure.
+       input)
       ((thing)
        (%gexp-input thing "out" (not target)))
       ((thing output)
@@ -1152,10 +1157,9 @@ applicable.
 When REFERENCES-GRAPHS is true, it must be a list of tuples of one of the
 following forms:
 
-  (FILE-NAME PACKAGE)
-  (FILE-NAME PACKAGE OUTPUT)
-  (FILE-NAME DERIVATION)
-  (FILE-NAME DERIVATION OUTPUT)
+  (FILE-NAME OBJ)
+  (FILE-NAME OBJ OUTPUT)
+  (FILE-NAME GEXP-INPUT)
   (FILE-NAME STORE-ITEM)
 
 The right-hand-side of each element of REFERENCES-GRAPHS is automatically made
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 871e5f7abb..001786c13c 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -1652,6 +1652,36 @@ importing.* \\(guix config\\) from the host"
                            read)
                          refs)))))))
 
+(test-assertm "references-file, non-default output"
+  (let* ((exp      #~(begin
+                       (mkdir #$output)
+                       (symlink #$%bootstrap-guile #$output:extra)))
+         (computed (computed-file "computed" exp
+                                  #:guile %bootstrap-guile))
+         (refs1    (references-file computed
+                                    #:guile %bootstrap-guile))
+         ;; Wrap COMPUTE in 'gexp-input' to get the "extra" output.
+         (refs2    (references-file (gexp-input computed "extra")
+                                    #:guile %bootstrap-guile)))
+    (mlet* %store-monad ((drv0 (lower-object %bootstrap-guile))
+                         (drv1 (lower-object computed))
+                         (drv2 (lower-object refs2))
+                         (drv3 (lower-object refs1)))
+      (mbegin %store-monad
+        (built-derivations (list drv2 drv3))
+        (mlet %store-monad ((refs ((store-lift requisites)
+                                   (list (derivation->output-path
+                                          drv1 "extra")))))
+          (return
+           (and (lset= string=?
+                       (call-with-input-file (derivation->output-path drv2)
+                         read)
+                       refs)
+                (lset= string=?
+                       (call-with-input-file (derivation->output-path drv3)
+                         read)
+                       (list (derivation->output-path drv1))))))))))
+
 (test-assert "lower-object & gexp-input-error?"
   (guard (c ((gexp-input-error? c)
              (gexp-error-invalid-input c)))



reply via email to

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