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.
This commit is contained in:
Ludovic Courtès 2016-06-16 22:05:10 +02:00
parent 762e54b7b4
commit 5dbae738f0
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 10 additions and 12 deletions

View File

@ -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>