mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-12-25 05:48:07 -05:00
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.
This commit is contained in:
parent
198df03756
commit
7a9f4822c0
2 changed files with 26 additions and 4 deletions
|
@ -8677,10 +8677,15 @@ Return the complete file name for @var{program} as found in
|
|||
@end deffn
|
||||
|
||||
@deffn {Scheme Procedure} search-input-file @var{inputs} @var{name}
|
||||
Return the complete file name for @var{name} as found in @var{inputs}.
|
||||
If @var{name} could not be found, an exception is raised instead.
|
||||
Here, @var{inputs} is an association list like @var{inputs} and
|
||||
@var{native-inputs} as available to build phases.
|
||||
@deffnx {Scheme Procedure} search-input-directory @var{inputs} @var{name}
|
||||
Return the complete file name for @var{name} as found in @var{inputs};
|
||||
@code{search-input-file} searches for a regular file and
|
||||
@code{search-input-directory} searches for a directory. If @var{name}
|
||||
could not be found, an exception is raised.
|
||||
|
||||
Here, @var{inputs} must be an association list like @code{inputs} and
|
||||
@code{native-inputs} as available to build phases (@pxref{Build
|
||||
Phases}).
|
||||
@end deffn
|
||||
|
||||
Here is a (simplified) example of how @code{search-input-file} is used
|
||||
|
|
|
@ -81,6 +81,7 @@ (define-module (guix build utils)
|
|||
list->search-path-as-string
|
||||
which
|
||||
search-input-file
|
||||
search-input-directory
|
||||
search-error?
|
||||
search-error-path
|
||||
search-error-file
|
||||
|
@ -633,6 +634,22 @@ (define (search-input-file inputs file)
|
|||
(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.
|
||||
|
|
Loading…
Reference in a new issue