summaryrefslogtreecommitdiff
path: root/guix/build
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-07-07 23:29:25 +0200
committerLudovic Courtès <ludo@gnu.org>2021-07-08 00:28:57 +0200
commit7a9f4822c0c431c25071977b68ab79d152887ec3 (patch)
treed8e44705829c6454b4fd769eb8e7349d75d02bd5 /guix/build
parent198df037562e7b4e0e90783dc5cba1e1c32f2110 (diff)
utils: Add 'search-input-directory'.
* guix/build/utils.scm (search-input-directory): New procedure. * doc/guix.texi (Build Utilities): Document it next to 'search-input-file'. Tweak wording.
Diffstat (limited to 'guix/build')
-rw-r--r--guix/build/utils.scm17
1 files changed, 17 insertions, 0 deletions
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 2636da392f..e7782d3e08 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -81,6 +81,7 @@
list->search-path-as-string
which
search-input-file
+ search-input-directory
search-error?
search-error-path
search-error-file
@@ -633,6 +634,22 @@ raised."
(or (search-path directories file)
(raise (condition (&search-error (path directories) (file file))))))))
+(define (search-input-directory inputs directory)
+ "Find a sub-directory named DIRECTORY among the INPUTS and return its
+absolute file name.
+
+DIRECTORY must be a string like \"xml/dtd/docbook\". If DIRECTORY is not
+found, an exception is raised."
+ (match inputs
+ (((_ . directories) ...)
+ (or (any (lambda (parent)
+ (let ((directory (string-append parent "/" directory)))
+ (and (directory-exists? directory)
+ directory)))
+ directories)
+ (raise (condition
+ (&search-error (path directories) (file directory))))))))
+
;;;
;;; Phases.