summaryrefslogtreecommitdiff
path: root/guix/utils.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-06-16 22:05:10 +0200
committerLudovic Courtès <ludo@gnu.org>2016-06-16 23:50:44 +0200
commit5dbae738f0ff83bf629b53d6f4e52a8384a97fb1 (patch)
tree82f7c1c21d24d3b436f4a24bc9b92fec45b9589b /guix/utils.scm
parent762e54b7b476982c007c9da96b3b17476a6f1d93 (diff)
downloadgnu-guix-5dbae738f0ff83bf629b53d6f4e52a8384a97fb1.tar
gnu-guix-5dbae738f0ff83bf629b53d6f4e52a8384a97fb1.tar.gz
utils: 'current-source-directory' is now purely an expansion-time thing.
* guix/utils.scm (extract-directory): Remove. (current-source-directory): Rewrite as a 'syntax-case' macro.
Diffstat (limited to 'guix/utils.scm')
-rw-r--r--guix/utils.scm22
1 files changed, 10 insertions, 12 deletions
diff --git a/guix/utils.scm b/guix/utils.scm
index 19fd0b0844..8aadfb0075 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -702,18 +702,16 @@ output port, and PROC's result is returned."
;;; Source location.
;;;
-(define (extract-directory properties)
- "Extract the directory name from source location PROPERTIES."
- (match (assq 'filename properties)
- (('filename . (? string? file-name))
- (dirname file-name))
- (_
- #f)))
-
-(define-syntax-rule (current-source-directory)
- "Expand to the directory of the current source file or #f if it could not
-be determined."
- (extract-directory (current-source-location)))
+(define-syntax current-source-directory
+ (lambda (s)
+ "Return the current directory name or #f if it could not be determined."
+ (syntax-case s ()
+ ((_)
+ (match (assq 'filename (syntax-source s))
+ (('filename . (? string? file-name))
+ (dirname file-name))
+ (_
+ #f))))))
;; A source location.
(define-record-type <location>