build-system/haskell: Accept line breaks in config files.
Long id’s will break to the next line. * guix/build/haskell-build-system.scm (grep): Remove. (register): Modify regular expression to account for newlines between key and value, fail if package id is empty.
This commit is contained in:
parent
7cdb65dc9c
commit
a01daed62c
1 changed files with 10 additions and 14 deletions
|
@ -143,17 +143,6 @@ and parameters ~s~%"
|
||||||
(find-files lib "\\.a$"))))
|
(find-files lib "\\.a$"))))
|
||||||
#t)
|
#t)
|
||||||
|
|
||||||
(define (grep rx port)
|
|
||||||
"Given a regular-expression RX including a group, read from PORT until the
|
|
||||||
first match and return the content of the group."
|
|
||||||
(let ((line (read-line port)))
|
|
||||||
(if (eof-object? line)
|
|
||||||
#f
|
|
||||||
(let ((rx-result (regexp-exec rx line)))
|
|
||||||
(if rx-result
|
|
||||||
(match:substring rx-result 1)
|
|
||||||
(grep rx port))))))
|
|
||||||
|
|
||||||
(define* (setup-compiler #:key system inputs outputs #:allow-other-keys)
|
(define* (setup-compiler #:key system inputs outputs #:allow-other-keys)
|
||||||
"Setup the compiler environment."
|
"Setup the compiler environment."
|
||||||
(let* ((haskell (assoc-ref inputs "haskell"))
|
(let* ((haskell (assoc-ref inputs "haskell"))
|
||||||
|
@ -242,7 +231,7 @@ given Haskell package."
|
||||||
(config-dir (string-append lib
|
(config-dir (string-append lib
|
||||||
"/ghc-" version
|
"/ghc-" version
|
||||||
"/" name ".conf.d"))
|
"/" name ".conf.d"))
|
||||||
(id-rx (make-regexp "^id: *(.*)$"))
|
(id-rx (make-regexp "^id:[ \n\t]+([^ \t\n]+)$" regexp/newline))
|
||||||
(config-file (string-append out "/" name ".conf"))
|
(config-file (string-append out "/" name ".conf"))
|
||||||
(params
|
(params
|
||||||
(list (string-append "--gen-pkg-config=" config-file))))
|
(list (string-append "--gen-pkg-config=" config-file))))
|
||||||
|
@ -250,8 +239,15 @@ given Haskell package."
|
||||||
;; The conf file is created only when there is a library to register.
|
;; The conf file is created only when there is a library to register.
|
||||||
(when (file-exists? config-file)
|
(when (file-exists? config-file)
|
||||||
(mkdir-p config-dir)
|
(mkdir-p config-dir)
|
||||||
(let ((config-file-name+id
|
(let* ((contents (call-with-input-file config-file read-string))
|
||||||
(call-with-ascii-input-file config-file (cut grep id-rx <>))))
|
(config-file-name+id (match:substring (first (list-matches id-rx contents)) 1)))
|
||||||
|
|
||||||
|
(when (or
|
||||||
|
(and
|
||||||
|
(string? config-file-name+id)
|
||||||
|
(string-null? config-file-name+id))
|
||||||
|
(not config-file-name+id))
|
||||||
|
(error (format #f "The package id for ~a is empty. This is a bug." config-file)))
|
||||||
|
|
||||||
;; Remove reference to "doc" output from "lib" (or "out") by rewriting the
|
;; Remove reference to "doc" output from "lib" (or "out") by rewriting the
|
||||||
;; "haddock-interfaces" field and removing the optional "haddock-html"
|
;; "haddock-interfaces" field and removing the optional "haddock-html"
|
||||||
|
|
Reference in a new issue