mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-08 12:20:41 -05:00
gexp: Add 'with-build-variables'.
* guix/gexp.scm (with-build-variables): New procedure.
This commit is contained in:
parent
cea364e7ff
commit
789babb761
1 changed files with 25 additions and 0 deletions
|
@ -104,6 +104,7 @@ (define-module (guix gexp)
|
|||
lowered-gexp-load-path
|
||||
lowered-gexp-load-compiled-path
|
||||
|
||||
with-build-variables
|
||||
gexp->derivation
|
||||
gexp->file
|
||||
gexp->script
|
||||
|
@ -1786,6 +1787,30 @@ (define* (load-path-expression modules #:optional (path %load-path)
|
|||
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)
|
||||
|
|
Loading…
Reference in a new issue