import: hackage: Emit native-inputs in the importer.
* guix/import/cabal.scm (cabal-custom-setup-dependencies): Export. (cabal-package-custom-setup): Export. (<cabal-package>): New field "custom-setup". (make-cabal-package): Modify. (eval-cabal): Modify. * guix/import/hackage.scm (cabal-dependencies->names): Factor out... (cabal-test-dependencies->names): ...this. (cabal-custom-setup-dependencies->names): New procedure. (hackage-module->sexp): Modify.
This commit is contained in:
parent
9dafb64711
commit
d804d0b9ef
|
@ -34,6 +34,8 @@
|
||||||
#:export (read-cabal
|
#:export (read-cabal
|
||||||
eval-cabal
|
eval-cabal
|
||||||
|
|
||||||
|
cabal-custom-setup-dependencies
|
||||||
|
|
||||||
cabal-package?
|
cabal-package?
|
||||||
cabal-package-name
|
cabal-package-name
|
||||||
cabal-package-version
|
cabal-package-version
|
||||||
|
@ -47,6 +49,7 @@
|
||||||
cabal-package-test-suites
|
cabal-package-test-suites
|
||||||
cabal-package-flags
|
cabal-package-flags
|
||||||
cabal-package-eval-environment
|
cabal-package-eval-environment
|
||||||
|
cabal-package-custom-setup
|
||||||
|
|
||||||
cabal-source-repository?
|
cabal-source-repository?
|
||||||
cabal-source-repository-use-case
|
cabal-source-repository-use-case
|
||||||
|
@ -616,7 +619,7 @@ If #f use the function 'port-filename' to obtain it."
|
||||||
(make-cabal-package name version license home-page source-repository
|
(make-cabal-package name version license home-page source-repository
|
||||||
synopsis description
|
synopsis description
|
||||||
executables lib test-suites
|
executables lib test-suites
|
||||||
flags eval-environment)
|
flags eval-environment custom-setup)
|
||||||
cabal-package?
|
cabal-package?
|
||||||
(name cabal-package-name)
|
(name cabal-package-name)
|
||||||
(version cabal-package-version)
|
(version cabal-package-version)
|
||||||
|
@ -629,7 +632,8 @@ If #f use the function 'port-filename' to obtain it."
|
||||||
(lib cabal-package-library) ; 'library' is a Scheme keyword
|
(lib cabal-package-library) ; 'library' is a Scheme keyword
|
||||||
(test-suites cabal-package-test-suites)
|
(test-suites cabal-package-test-suites)
|
||||||
(flags cabal-package-flags)
|
(flags cabal-package-flags)
|
||||||
(eval-environment cabal-package-eval-environment)) ; alist
|
(eval-environment cabal-package-eval-environment) ; alist
|
||||||
|
(custom-setup cabal-package-custom-setup))
|
||||||
|
|
||||||
(set-record-type-printer! <cabal-package>
|
(set-record-type-printer! <cabal-package>
|
||||||
(lambda (package port)
|
(lambda (package port)
|
||||||
|
@ -826,10 +830,13 @@ See the manual for limitations.")))))))
|
||||||
(lib (make-cabal-section evaluated-sexp 'library))
|
(lib (make-cabal-section evaluated-sexp 'library))
|
||||||
(test-suites (make-cabal-section evaluated-sexp 'test-suite))
|
(test-suites (make-cabal-section evaluated-sexp 'test-suite))
|
||||||
(flags (make-cabal-section evaluated-sexp 'flag))
|
(flags (make-cabal-section evaluated-sexp 'flag))
|
||||||
(eval-environment '()))
|
(eval-environment '())
|
||||||
|
(custom-setup (match
|
||||||
|
(make-cabal-section evaluated-sexp 'custom-setup)
|
||||||
|
((x) x))))
|
||||||
(make-cabal-package name version license home-page-or-hackage
|
(make-cabal-package name version license home-page-or-hackage
|
||||||
source-repository synopsis description executables lib
|
source-repository synopsis description executables lib
|
||||||
test-suites flags eval-environment)))
|
test-suites flags eval-environment custom-setup)))
|
||||||
|
|
||||||
((compose cabal-evaluated-sexp->package eval) cabal-sexp))
|
((compose cabal-evaluated-sexp->package eval) cabal-sexp))
|
||||||
|
|
||||||
|
|
|
@ -150,10 +150,9 @@ version."
|
||||||
(_ #f)))
|
(_ #f)))
|
||||||
|
|
||||||
|
|
||||||
(define (cabal-dependencies->names cabal include-test-dependencies?)
|
(define (cabal-dependencies->names cabal)
|
||||||
"Return the list of dependencies names from the CABAL package object. If
|
"Return the list of dependencies names from the CABAL package object,
|
||||||
INCLUDE-TEST-DEPENDENCIES? is #f, do not include dependencies required by test
|
not including test suite dependencies or custom-setup dependencies."
|
||||||
suites."
|
|
||||||
(let* ((lib (cabal-package-library cabal))
|
(let* ((lib (cabal-package-library cabal))
|
||||||
(lib-deps (if (pair? lib)
|
(lib-deps (if (pair? lib)
|
||||||
(map cabal-dependency-name
|
(map cabal-dependency-name
|
||||||
|
@ -163,15 +162,25 @@ suites."
|
||||||
(exe-deps (if (pair? exe)
|
(exe-deps (if (pair? exe)
|
||||||
(map cabal-dependency-name
|
(map cabal-dependency-name
|
||||||
(append-map cabal-executable-dependencies exe))
|
(append-map cabal-executable-dependencies exe))
|
||||||
'()))
|
|
||||||
(ts (cabal-package-test-suites cabal))
|
|
||||||
(ts-deps (if (pair? ts)
|
|
||||||
(map cabal-dependency-name
|
|
||||||
(append-map cabal-test-suite-dependencies ts))
|
|
||||||
'())))
|
'())))
|
||||||
(if include-test-dependencies?
|
(delete-duplicates (append lib-deps exe-deps))))
|
||||||
(delete-duplicates (append lib-deps exe-deps ts-deps))
|
|
||||||
(delete-duplicates (append lib-deps exe-deps)))))
|
(define (cabal-test-dependencies->names cabal)
|
||||||
|
"Return the list of test suite dependencies from the CABAL package
|
||||||
|
object."
|
||||||
|
(let* ((ts (cabal-package-test-suites cabal))
|
||||||
|
(ts-deps (if (pair? ts)
|
||||||
|
(map cabal-dependency-name
|
||||||
|
(append-map cabal-test-suite-dependencies ts))
|
||||||
|
'())))
|
||||||
|
ts-deps))
|
||||||
|
|
||||||
|
(define (cabal-custom-setup-dependencies->names cabal)
|
||||||
|
"Return the list of custom-setup dependencies from the CABAL package
|
||||||
|
object."
|
||||||
|
(let* ((custom-setup-dependencies (and=> (cabal-package-custom-setup cabal)
|
||||||
|
cabal-custom-setup-dependencies)))
|
||||||
|
(map cabal-dependency-name custom-setup-dependencies)))
|
||||||
|
|
||||||
(define (filter-dependencies dependencies own-name)
|
(define (filter-dependencies dependencies own-name)
|
||||||
"Filter the dependencies included with the GHC compiler from DEPENDENCIES, a
|
"Filter the dependencies included with the GHC compiler from DEPENDENCIES, a
|
||||||
|
@ -199,8 +208,23 @@ representation of a Cabal file as produced by 'read-cabal'."
|
||||||
(map hackage-name->package-name
|
(map hackage-name->package-name
|
||||||
((compose (cut filter-dependencies <>
|
((compose (cut filter-dependencies <>
|
||||||
(cabal-package-name cabal))
|
(cabal-package-name cabal))
|
||||||
(cut cabal-dependencies->names <>
|
(cut cabal-dependencies->names <>))
|
||||||
include-test-dependencies?))
|
cabal))))
|
||||||
|
(map (lambda (name)
|
||||||
|
(list name (list 'unquote (string->symbol name))))
|
||||||
|
names)))
|
||||||
|
|
||||||
|
(define native-dependencies
|
||||||
|
(let ((names
|
||||||
|
(map hackage-name->package-name
|
||||||
|
((compose (cut filter-dependencies <>
|
||||||
|
(cabal-package-name cabal))
|
||||||
|
;; FIXME: Check include-test-dependencies?
|
||||||
|
(lambda (cabal)
|
||||||
|
(append (if include-test-dependencies?
|
||||||
|
(cabal-test-dependencies->names cabal)
|
||||||
|
'())
|
||||||
|
(cabal-custom-setup-dependencies->names cabal))))
|
||||||
cabal))))
|
cabal))))
|
||||||
(map (lambda (name)
|
(map (lambda (name)
|
||||||
(list name (list 'unquote (string->symbol name))))
|
(list name (list 'unquote (string->symbol name))))
|
||||||
|
@ -234,6 +258,7 @@ representation of a Cabal file as produced by 'read-cabal'."
|
||||||
"failed to download tar archive")))))
|
"failed to download tar archive")))))
|
||||||
(build-system haskell-build-system)
|
(build-system haskell-build-system)
|
||||||
,@(maybe-inputs 'inputs dependencies)
|
,@(maybe-inputs 'inputs dependencies)
|
||||||
|
,@(maybe-inputs 'native-inputs native-dependencies)
|
||||||
,@(maybe-arguments)
|
,@(maybe-arguments)
|
||||||
(home-page ,(cabal-package-home-page cabal))
|
(home-page ,(cabal-package-home-page cabal))
|
||||||
(synopsis ,(cabal-package-synopsis cabal))
|
(synopsis ,(cabal-package-synopsis cabal))
|
||||||
|
|
Loading…
Reference in New Issue