build-system/gnu: Add support for non-directory search paths.
Partly fixes <http://bugs.gnu.org/18033>. * guix/build/utils.scm (search-path-as-list): Rename 'sub-directories' parameter to 'files'. Add #:type parameter and honor it. (set-path-environment-variable): Likewise. Pass #:type to 'search-path-as-list'. * guix/packages.scm (search-path-specification->sexp): Add 'directory as the last item of the tuple. * guix/build/gnu-build-system.scm (set-paths): Add 'type' to search-path pattern. Pass #:type to 'set-path-environment-variable'.
This commit is contained in:
parent
8c89f514bf
commit
6aa47e3883
|
@ -73,19 +73,21 @@
|
||||||
input-directories)))
|
input-directories)))
|
||||||
|
|
||||||
(for-each (match-lambda
|
(for-each (match-lambda
|
||||||
((env-var (directories ...) separator)
|
((env-var (files ...) separator type)
|
||||||
(set-path-environment-variable env-var directories
|
(set-path-environment-variable env-var files
|
||||||
input-directories
|
input-directories
|
||||||
#:separator separator)))
|
#:separator separator
|
||||||
|
#:type type)))
|
||||||
search-paths)
|
search-paths)
|
||||||
|
|
||||||
(when native-search-paths
|
(when native-search-paths
|
||||||
;; Search paths for native inputs, when cross building.
|
;; Search paths for native inputs, when cross building.
|
||||||
(for-each (match-lambda
|
(for-each (match-lambda
|
||||||
((env-var (directories ...) separator)
|
((env-var (files ...) separator type)
|
||||||
(set-path-environment-variable env-var directories
|
(set-path-environment-variable env-var files
|
||||||
native-input-directories
|
native-input-directories
|
||||||
#:separator separator)))
|
#:separator separator
|
||||||
|
#:type type)))
|
||||||
native-search-paths))
|
native-search-paths))
|
||||||
|
|
||||||
#t)
|
#t)
|
||||||
|
|
|
@ -290,9 +290,10 @@ matches REGEXP."
|
||||||
;;; Search paths.
|
;;; Search paths.
|
||||||
;;;
|
;;;
|
||||||
|
|
||||||
(define (search-path-as-list sub-directories input-dirs)
|
(define* (search-path-as-list files input-dirs
|
||||||
"Return the list of directories among SUB-DIRECTORIES that exist in
|
#:key (type 'directory))
|
||||||
INPUT-DIRS. Example:
|
"Return the list of directories among FILES of the given TYPE (a symbol as
|
||||||
|
returned by 'stat:type') that exist in INPUT-DIRS. Example:
|
||||||
|
|
||||||
(search-path-as-list '(\"share/emacs/site-lisp\" \"share/emacs/24.1\")
|
(search-path-as-list '(\"share/emacs/site-lisp\" \"share/emacs/24.1\")
|
||||||
(list \"/package1\" \"/package2\" \"/package3\"))
|
(list \"/package1\" \"/package2\" \"/package3\"))
|
||||||
|
@ -301,12 +302,12 @@ INPUT-DIRS. Example:
|
||||||
|
|
||||||
"
|
"
|
||||||
(append-map (lambda (input)
|
(append-map (lambda (input)
|
||||||
(filter-map (lambda (dir)
|
(filter-map (lambda (file)
|
||||||
(let ((dir (string-append input "/"
|
(let* ((file (string-append input "/" file))
|
||||||
dir)))
|
(stat (stat file #f)))
|
||||||
(and (directory-exists? dir)
|
(and stat (eq? type (stat:type stat))
|
||||||
dir)))
|
file)))
|
||||||
sub-directories))
|
files))
|
||||||
input-dirs))
|
input-dirs))
|
||||||
|
|
||||||
(define (list->search-path-as-string lst separator)
|
(define (list->search-path-as-string lst separator)
|
||||||
|
@ -315,16 +316,20 @@ INPUT-DIRS. Example:
|
||||||
(define* (search-path-as-string->list path #:optional (separator #\:))
|
(define* (search-path-as-string->list path #:optional (separator #\:))
|
||||||
(string-tokenize path (char-set-complement (char-set separator))))
|
(string-tokenize path (char-set-complement (char-set separator))))
|
||||||
|
|
||||||
(define* (set-path-environment-variable env-var sub-directories input-dirs
|
(define* (set-path-environment-variable env-var files input-dirs
|
||||||
#:key (separator ":"))
|
#:key
|
||||||
"Look for each of SUB-DIRECTORIES in INPUT-DIRS. Set ENV-VAR to a
|
(separator ":")
|
||||||
SEPARATOR-separated path accordingly. Example:
|
(type 'directory))
|
||||||
|
"Look for each of FILES of the given TYPE (a symbol as returned by
|
||||||
|
'stat:type') in INPUT-DIRS. Set ENV-VAR to a SEPARATOR-separated path
|
||||||
|
accordingly. Example:
|
||||||
|
|
||||||
(set-path-environment-variable \"PKG_CONFIG\"
|
(set-path-environment-variable \"PKG_CONFIG\"
|
||||||
'(\"lib/pkgconfig\")
|
'(\"lib/pkgconfig\")
|
||||||
(list package1 package2))
|
(list package1 package2))
|
||||||
"
|
"
|
||||||
(let* ((path (search-path-as-list sub-directories input-dirs))
|
(let* ((path (search-path-as-list files input-dirs
|
||||||
|
#:type type))
|
||||||
(value (list->search-path-as-string path separator)))
|
(value (list->search-path-as-string path separator)))
|
||||||
(if (string-null? value)
|
(if (string-null? value)
|
||||||
(begin
|
(begin
|
||||||
|
|
|
@ -180,7 +180,8 @@ representation."
|
||||||
corresponds to the arguments expected by `set-path-environment-variable'."
|
corresponds to the arguments expected by `set-path-environment-variable'."
|
||||||
(match spec
|
(match spec
|
||||||
(($ <search-path-specification> variable directories separator)
|
(($ <search-path-specification> variable directories separator)
|
||||||
`(,variable ,directories ,separator))))
|
;; TODO: Allow other values of TYPE. See <http://bugs.gnu.org/18033>.
|
||||||
|
`(,variable ,directories ,separator directory))))
|
||||||
|
|
||||||
(define %supported-systems
|
(define %supported-systems
|
||||||
;; This is the list of system types that are supported. By default, we
|
;; This is the list of system types that are supported. By default, we
|
||||||
|
|
Loading…
Reference in New Issue