[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
12/29: gexp: Add 'with-build-variables'.
From: |
guix-commits |
Subject: |
12/29: gexp: Add 'with-build-variables'. |
Date: |
Mon, 8 Mar 2021 06:24:51 -0500 (EST) |
civodul pushed a commit to branch wip-build-systems-gexp
in repository guix.
commit 9514caaebf0b863f4302a26f906f3a017e6a2157
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Mon Mar 8 09:39:27 2021 +0100
gexp: Add 'with-build-variables'.
* guix/gexp.scm (with-build-variables): New procedure.
---
guix/gexp.scm | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/guix/gexp.scm b/guix/gexp.scm
index e9b8503..c7fabfe 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -104,6 +104,7 @@
lowered-gexp-load-path
lowered-gexp-load-compiled-path
+ with-build-variables
gexp->derivation
gexp->file
gexp->script
@@ -1785,6 +1786,30 @@ are searched for in PATH. Return #f when MODULES and
EXTENSIONS are empty."
extensions))
%load-compiled-path)))))))))
+(define (with-build-variables inputs outputs body)
+ "Return a gexp that surrounds BODY with a definition of the legacy
+'%build-inputs', '%outputs', and '%output' variables based on INPUTS, a list
+of name/gexp-input tuples, and OUTPUTS, a list of strings."
+
+ ;; These two variables are defined for backward compatibility. They are
+ ;; used by package expressions. These must be top-level defines so that
+ ;; 'use-modules' form in BODY that are required for macro expansion work as
+ ;; expected.
+ (gexp (begin
+ (define %build-inputs
+ (map (lambda (tuple)
+ (apply cons tuple))
+ '(ungexp inputs)))
+ (define %outputs
+ (list (ungexp-splicing
+ (map (lambda (name)
+ (gexp (cons (ungexp name)
+ (ungexp output name))))
+ outputs))))
+ (define %output
+ (assoc-ref %outputs "out"))
+ (ungexp body))))
+
(define* (gexp->script name exp
#:key (guile (default-guile))
(module-path %load-path)
- 28/29: grafts: Add 'without-grafting'., (continued)
- 28/29: grafts: Add 'without-grafting'., guix-commits, 2021/03/08
- 29/29: gexp: Allowed/disallowed references and graphs never refer to grafted inputs., guix-commits, 2021/03/08
- 14/29: build-system: Rewrite using gexps., guix-commits, 2021/03/08
- 15/29: packages: Turn 'bag->derivation' into a monadic procedure., guix-commits, 2021/03/08
- 16/29: packages: Simplify patch instantiation., guix-commits, 2021/03/08
- 25/29: tests: Refer to '%derivation-cache' in the right module., guix-commits, 2021/03/08
- 26/29: packages: 'expand-input' accepts any file-like object., guix-commits, 2021/03/08
- 17/29: packages: Core procedures are written in monadic style., guix-commits, 2021/03/08
- 19/29: gexp: Add 'sexp->gexp'., guix-commits, 2021/03/08
- 05/29: gexp: Micro-optimize sexp serialization., guix-commits, 2021/03/08
- 12/29: gexp: Add 'with-build-variables'.,
guix-commits <=
- 18/29: packages: Default origin 'patch-flags' is a gexp., guix-commits, 2021/03/08
- 22/29: gexp: Honor #:target in 'compiled-modules'., guix-commits, 2021/03/08
- 23/29: packages: '%standard-patch-inputs' is not influenced by '%current-target-system'., guix-commits, 2021/03/08
- 24/29: download: 'url-fetch/tarbomb' and 'url-fetch/zipbomb' refer to native tools., guix-commits, 2021/03/08
- 27/29: packages: Call 'bag-grafts' only on the tip of the package graph., guix-commits, 2021/03/08