all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxime Devos <maximedevos@telenet.be>
To: 49025@debbugs.gnu.org
Subject: [bug#49025] [PATCH core-updates 03/37] packages: Define this-package-input and this-package-native-input.
Date: Mon, 14 Jun 2021 17:37:19 +0200	[thread overview]
Message-ID: <d5a0fb91ad0c084ec12d66c45cabc27af0d212e9.camel@telenet.be> (raw)
In-Reply-To: <cover.1623680697.git.maximedevos@telenet.be>

[-- Attachment #1: Type: text/plain, Size: 527 bytes --]

These macros are intended to be used in build phases.
More precisely, (assoc-ref %build-inputs "input") can be
replaced by #$(this-package-input "input") or #+(this-package-native-input
"native-input") as appropriate.

* guix/packages.scm
  (package-input, package-native-input): New (unexported) procedures.
  (this-package-input, this-package-native-input): New macros.
---
 guix/packages.scm  | 29 +++++++++++++++++++++++++++++
 tests/packages.scm | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+)


[-- Attachment #2: 0003-packages-Define-this-package-input-and-this-package-.patch --]
[-- Type: text/x-patch, Size: 3333 bytes --]

diff --git a/guix/packages.scm b/guix/packages.scm
index a66dbea1b7..80c8bbebf0 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -108,6 +108,9 @@
             deprecated-package
             package-field-location
 
+            this-package-input
+            this-package-native-input
+
             package-direct-sources
             package-transitive-sources
             package-direct-inputs
@@ -513,6 +516,32 @@ object."
         #f)))
     (_ #f)))
 
+(define (package-input package name)
+  "Return the package input NAME of PACKAGE--i.e., an input
+from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
+considered.  If this input does not exist, return #f instead."
+  (and=> (or (assoc-ref (package-inputs package) name)
+             (assoc-ref (package-propagated-inputs package) name))
+         car))
+
+(define (package-native-input package name)
+  "Return the native package input NAME of PACKAGE--i.e., an input
+from the ‘native-inputs’ field. If this native input does not exist,
+return #f instead."
+  (and=> (assoc-ref (package-native-inputs package) name)
+         car))
+
+(define-syntax-rule (this-package-input name)
+  "Return the input NAME of the package being defined--i.e., an input
+from the ‘inputs’ or ‘propagated-inputs’ field.  Native inputs are not
+considered.  If this input does not exist, return #f instead."
+  (package-input this-package name))
+
+(define-syntax-rule (this-package-native-input name)
+  "Return the native package input NAME of the package being defined--i.e.,
+an input from the ‘native-inputs’ field.  If this native input does not
+exist, return #f instead."
+  (package-native-input this-package name))
 
 ;; Error conditions.
 
diff --git a/tests/packages.scm b/tests/packages.scm
index 47d10af5bc..91ec38e4cc 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021 Maxime Devos <maximedevos@telenet.be>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1851,6 +1852,39 @@
   (package-location (specification->package "guile@2"))
   (specification->location "guile@2"))
 
+(test-eq "this-package-input, exists"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (inputs `(("hello" ,hello)))
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-input, exists in propagated-inputs"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (propagated-inputs `(("hello" ,hello)))
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-input, does not exist"
+  #f
+  (package-arguments
+   (dummy-package "a"
+     (arguments (this-package-input "hello")))))
+
+(test-eq "this-package-native-input, exists"
+  hello
+  (package-arguments
+   (dummy-package "a"
+     (native-inputs `(("hello" ,hello)))
+     (arguments (this-package-native-input "hello")))))
+
+(test-eq "this-package-native-input, does not exists"
+  #f
+  (package-arguments
+   (dummy-package "a"
+     (arguments (this-package-native-input "hello")))))
+
 (test-end "packages")
 
 ;;; Local Variables:

  parent reply	other threads:[~2021-06-14 16:01 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1623680697.git.maximedevos@telenet.be>
2021-06-14 15:37 ` [bug#49025] [PATCH core-updates 08/37] libgpg-error: Remove trailing #f from phases Maxime Devos
2021-06-14 15:37 ` [bug#49025] [PATCH core-updates 09/37] libgpg-error: Prevent silent miscompilation some systems Maxime Devos
2021-06-14 15:37 ` [bug#49025] [PATCH core-updates 01/37] utils: Define target-linux? predicate Maxime Devos
2021-06-14 15:37 ` Maxime Devos [this message]
2021-06-14 15:37 ` [bug#49025] [PATCH core-updates 13/37] wrap-python3: Make #:builder a G-exp instead of a raw S-exp Maxime Devos
2021-06-14 15:37 ` [bug#49025] [PATCH core-updates 14/37] wrap-python3: Fix cross-compilation Maxime Devos
2021-06-14 15:37 ` [bug#49025] [PATCH core-updates 12/37] libgcrypt: Fix cross-compilation build error Maxime Devos
2021-06-14 15:37 ` [bug#49025] [PATCH core-updates 10/37] libgpgerror: Maybe fix a cross-compilation bug Maxime Devos
2021-06-14 15:37 ` [bug#49025] [PATCH core-updates 11/37] libgpg-error: Fix cross-compilation error Maxime Devos
2021-06-14 15:37 ` [bug#49025] [PATCH core-updates 16/37] openssl: Remove trailing #t from phases Maxime Devos
2021-06-14 15:37 ` [bug#49025] [PATCH core-updates 17/37] openssl: Make the #:phases argument a G-expression Maxime Devos
2021-06-14 15:37 ` [bug#49025] [PATCH core-updates 18/37] openssl: Use G-exp machinery for referring to outputs Maxime Devos
2021-06-14 15:37 ` [bug#49025] [PATCH core-updates 19/37] openssl: Move documentation instead of copying and deleting it Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 21/37] openssl: Find bin/env when cross-compiling Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 22/37] openssl: Extract logic for computing CONFIGURE_TARGET_ARCH Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 36/37] cross-base: Fix cross-compiler for i686-linux-gnu Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 04/37] net-base: Make #:builder argument a G-expression Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 05/37] net-base: Fix cross-compilation, eliminating %build-inputs & friends Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 06/37] net-base: Don't cross-compile Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 23/37] readline: Make #:configure-flags a G-expression Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 24/37] readline: Fix build error when cross-compiling Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 25/37] bash: Make #:configure-flags a G-expression Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 26/37] bash: Fix cross-compilation build error Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 27/37] fontconfig: Make the #:configure-flags argument a G-expression Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 28/37] fontconfig: Fix build error when cross-compiling Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 15/37] python: Fix reference to input " Maxime Devos
2021-06-14 15:38 ` [bug#49025] [PATCH core-updates 29/37] glib: Use a correct python in scripts " Maxime Devos
2021-06-14 15:39 ` [bug#49025] [PATCH core-updates 07/37] tzdata: Don't bother with cross-compiling Maxime Devos
2021-06-14 15:39 ` [bug#49025] [PATCH core-updates 30/37] glib: Verify the cross-compiled python is used in installed scripts Maxime Devos
2021-06-14 15:39 ` [bug#49025] [PATCH core-updates 37/37] meson: Support cross-compilation Maxime Devos
2021-06-14 15:39 ` [bug#49025] [PATCH core-updates 20/37] openssl: Move all man pages to separate output, not only man3 Maxime Devos
2021-06-14 15:39 ` [bug#49025] [PATCH core-updates 32/37] tk: Make #:configure-flags a G-expression Maxime Devos
2021-06-14 15:39 ` [bug#49025] [PATCH core-updates 34/37] libelf: Use the cross-compiler when cross-compiling Maxime Devos
2021-06-14 15:39 ` [bug#49025] [PATCH core-updates 33/37] tk: Do not use %build-inputs " Maxime Devos
2021-06-14 15:39 ` [bug#49025] [PATCH core-updates 35/37] opendht: Correct 'nettle' variable name in inputs Maxime Devos
2021-06-14 15:39 ` [bug#49025] [PATCH core-updates 31/37] glib: Look up "tzdata" in 'native-inputs', not 'inputs' Maxime Devos
2021-06-14 15:39 ` [bug#49025] [PATCH core-updates 02/37] utils: Define a target-x86-32? and target-x86-64? predicate Maxime Devos

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

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

  git send-email \
    --in-reply-to=d5a0fb91ad0c084ec12d66c45cabc27af0d212e9.camel@telenet.be \
    --to=maximedevos@telenet.be \
    --cc=49025@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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.