[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
03/08: utils: Add 'modify-phases'.
From: |
Ludovic Courtès |
Subject: |
03/08: utils: Add 'modify-phases'. |
Date: |
Thu, 26 Feb 2015 23:09:51 +0000 |
civodul pushed a commit to branch core-updates
in repository guix.
commit 8ddc41e1f25b643beaa204b1f5c271cfe7f3e0a9
Author: Ludovic Courtès <address@hidden>
Date: Thu Feb 26 22:48:14 2015 +0100
utils: Add 'modify-phases'.
* guix/build/utils.scm (modify-phases): New macro.
---
.dir-locals.el | 1 +
guix/build/utils.scm | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/.dir-locals.el b/.dir-locals.el
index e056e26..7aef853 100644
--- a/.dir-locals.el
+++ b/.dir-locals.el
@@ -20,6 +20,7 @@
(eval . (put 'guard 'scheme-indent-function 1))
(eval . (put 'lambda* 'scheme-indent-function 1))
(eval . (put 'substitute* 'scheme-indent-function 1))
+ (eval . (put 'modify-phases 'scheme-indent-function 1))
(eval . (put 'with-directory-excursion 'scheme-indent-function 1))
(eval . (put 'package 'scheme-indent-function 0))
(eval . (put 'origin 'scheme-indent-function 0))
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 6de1fa3..f24ed47 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -54,6 +54,7 @@
alist-cons-before
alist-cons-after
alist-replace
+ modify-phases
with-atomic-file-replacement
substitute
substitute*
@@ -423,6 +424,33 @@ An error is raised when no such pair exists."
((_ after ...)
(append before (alist-cons key value after))))))
+(define-syntax-rule (modify-phases phases mod-spec ...)
+ "Modify PHASES sequentially as per each MOD-SPEC, which may have one of the
+following forms:
+
+ (delete <old-phase-name>)
+ (replace <old-phase-name> <new-phase>)
+ (add-before <old-phase-name> <new-phase-name> <new-phase>)
+ (add-after <old-phase-name> <new-phase-name> <new-phase>)
+
+Where every <*-phase-name> is an automatically quoted symbol, and <new-phase>
+an expression evaluating to a procedure."
+ (let* ((phases* phases)
+ (phases* (%modify-phases phases* mod-spec))
+ ...)
+ phases*))
+
+(define-syntax %modify-phases
+ (syntax-rules (delete replace add-before add-after)
+ ((_ phases (delete old-phase-name))
+ (alist-delete 'old-phase-name phases))
+ ((_ phases (replace old-phase-name new-phase))
+ (alist-replace 'old-phase-name new-phase phases))
+ ((_ phases (add-before old-phase-name new-phase-name new-phase))
+ (alist-cons-before 'old-phase-name 'new-phase-name new-phase phases))
+ ((_ phases (add-after old-phase-name new-phase-name new-phase))
+ (alist-cons-after 'old-phase-name 'new-phase-name new-phase phases))))
+
;;;
;;; Text substitution (aka. sed).
- branch core-updates updated (a068dba -> f307947), Ludovic Courtès, 2015/02/26
- 01/08: Merge branch 'master' into core-updates, Ludovic Courtès, 2015/02/26
- 05/08: build-system/gnu: Add 'install-locale' phase., Ludovic Courtès, 2015/02/26
- 06/08: gnu: Add glibc-utf8-locales to the implicit inputs., Ludovic Courtès, 2015/02/26
- 08/08: ld-wrapper: Add '-rpath' for arguments such as 'libfoo.so.5.3'., Ludovic Courtès, 2015/02/26
- 02/08: build-system/gnu: Add support for zip archives., Ludovic Courtès, 2015/02/26
- 03/08: utils: Add 'modify-phases'.,
Ludovic Courtès <=
- 07/08: packages: When possible, use a UTF-8 locale in patch-and-repack., Ludovic Courtès, 2015/02/26
- 04/08: build-system: Use 'modify-phases'., Ludovic Courtès, 2015/02/26