unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 47310@debbugs.gnu.org
Cc: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Subject: [bug#47310] [PATCH 1/4] import: utils: Refactor maybe-inputs and add maybe-propagated-inputs.
Date: Mon, 22 Mar 2021 00:20:19 -0400	[thread overview]
Message-ID: <20210322042022.17385-1-maxim.cournoyer@gmail.com> (raw)
In-Reply-To: <87eeg7vn3d.fsf@gmail.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=yes, Size: 2943 bytes --]

* 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.
---
 guix/import/utils.scm | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

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





  reply	other threads:[~2021-03-22  4:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22  4:10 [bug#47310] [PATCH 0/4] Improve parsing of synopsis and description, add pinned versions mode Maxim Cournoyer
2021-03-22  4:20 ` Maxim Cournoyer [this message]
2021-03-22  4:20   ` [bug#47310] [PATCH 2/4] import: go: Improve synopsis and description parsing Maxim Cournoyer
2021-03-22  4:20   ` [bug#47310] [PATCH 3/4] import: go: Add an option to use pinned versions Maxim Cournoyer
2021-04-10  3:13     ` bug#47310: " Maxim Cournoyer
2021-03-22  4:20   ` [bug#47310] [PATCH 4/4] import: go: Append version to symbol name in the pinned version mode Maxim Cournoyer
2021-04-10 20:54 ` [bug#47310] [PATCH 0/4] go importer: Better synopsis and descriptions, pinned versions mode Ludovic Courtès
2021-04-11  0:57   ` Maxim Cournoyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210322042022.17385-1-maxim.cournoyer@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=47310@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).