[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#49025] [PATCH v4 core-updates 03/36] packages: Define this-package-
From: |
Maxime Devos |
Subject: |
[bug#49025] [PATCH v4 core-updates 03/36] packages: Define this-package-input and this-package-native-input. |
Date: |
Sat, 19 Jun 2021 17:04:25 +0200 |
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(+)
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:
--
2.32.0
- [bug#49025] [PATCH v3 core-updates 24/37] readline: Fix build error when cross-compiling., (continued)
- [bug#49025] [PATCH v4 core-updates 00/36] Support cross-compilation with meson, Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 01/36] utils: Define target-linux? predicate., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 02/36] utils: Define a target-x86-32? and target-x86-64? predicate., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 05/36] net-base: Fix cross-compilation, eliminating %build-inputs & friends, Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 04/36] net-base: Make #:builder argument a G-expression., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 06/36] net-base: Don't cross-compile., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 03/36] packages: Define this-package-input and this-package-native-input.,
Maxime Devos <=
- [bug#49025] [PATCH v4 core-updates 08/36] libgpg-error: Remove trailing #f from phases., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 07/36] tzdata: Don't bother with cross-compiling., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 10/36] libgpgerror: Maybe fix a cross-compilation bug., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 11/36] libgpg-error: Fix cross-compilation error., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 13/36] wrap-python3: Make #:builder a G-exp instead of a raw S-exp., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 14/36] wrap-python3: Fix cross-compilation., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 17/36] openssl: Make the #:phases argument a G-expression., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 24/36] readline: Fix build error when cross-compiling., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 30/36] glib: Verify the cross-compiled python is used in installed scripts., Maxime Devos, 2021/06/19
- [bug#49025] [PATCH v4 core-updates 28/36] fontconfig: Fix build error when cross-compiling., Maxime Devos, 2021/06/19