me
/
guix
Archived
1
0
Fork 0

import: utils: Refactor maybe-inputs and add maybe-propagated-inputs.

* guix/import/utils.scm (maybe-inputs)[type]: New argument.  Update docstring.
The argument is used to derive the input field name to use.
(maybe-native-inputs): Adjust to use the above.
(maybe-propagated-inputs): New procedure.
master
Maxim Cournoyer 2021-03-05 09:21:14 -05:00
parent b685337c94
commit 2446a112df
No known key found for this signature in database
GPG Key ID: 1260E46482E63562
1 changed files with 22 additions and 14 deletions

View File

@ -7,6 +7,7 @@
;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net> ;;; Copyright © 2019 Robert Vollmert <rob@vllmrt.net>
;;; Copyright © 2020 Helio Machado <0x2b3bfa0+guix@googlemail.com> ;;; Copyright © 2020 Helio Machado <0x2b3bfa0+guix@googlemail.com>
;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net> ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; ;;;
;;; This file is part of GNU Guix. ;;; This file is part of GNU Guix.
;;; ;;;
@ -57,6 +58,7 @@
package-names->package-inputs package-names->package-inputs
maybe-inputs maybe-inputs
maybe-native-inputs maybe-native-inputs
maybe-propagated-inputs
package->definition package->definition
spdx-string->license spdx-string->license
@ -247,23 +249,29 @@ use in an 'inputs' field of a package definition."
(input (make-input input #f))) (input (make-input input #f)))
names)) names))
(define* (maybe-inputs package-names #:optional (output #f)) (define* (maybe-inputs package-names #:optional (output #f)
#:key (type #f))
"Given a list of PACKAGE-NAMES, tries to generate the 'inputs' field of a "Given a list of PACKAGE-NAMES, tries to generate the 'inputs' field of a
package definition." package definition. TYPE can be used to specify the type of the inputs;
(match (package-names->package-inputs package-names output) either the 'native or 'propagated symbols are accepted. Left unspecified, the
(() snippet generated is for regular inputs."
'()) (let ((field-name (match type
((package-inputs ...) ('native 'native-inputs)
`((inputs (,'quasiquote ,package-inputs)))))) ('propagated 'propagated-inputs)
(_ 'inputs))))
(match (package-names->package-inputs package-names output)
(()
'())
((package-inputs ...)
`((,field-name (,'quasiquote ,package-inputs)))))))
(define* (maybe-native-inputs package-names #:optional (output #f)) (define* (maybe-native-inputs package-names #:optional (output #f))
"Given a list of PACKAGE-NAMES, tries to generate the 'inputs' field of a "Same as MAYBE-INPUTS, but for native inputs."
package definition." (maybe-inputs package-names output #:type 'native))
(match (package-names->package-inputs package-names output)
(() (define* (maybe-propagated-inputs package-names #:optional (output #f))
'()) "Same as MAYBE-INPUTS, but for propagated inputs."
((package-inputs ...) (maybe-inputs package-names output #:type 'propagated))
`((native-inputs (,'quasiquote ,package-inputs))))))
(define* (package->definition guix-package #:optional append-version?/string) (define* (package->definition guix-package #:optional append-version?/string)
"If APPEND-VERSION?/STRING is #t, append the package's major+minor "If APPEND-VERSION?/STRING is #t, append the package's major+minor