From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id SOA8JxjH7mAnAQAAgWs5BA (envelope-from ) for ; Wed, 14 Jul 2021 13:14:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id QEv3IhjH7mDEDgAA1q6Kng (envelope-from ) for ; Wed, 14 Jul 2021 11:14:32 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 805E515990 for ; Wed, 14 Jul 2021 13:14:31 +0200 (CEST) Received: from localhost ([::1]:46460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3cqU-0001f1-GZ for larch@yhetil.org; Wed, 14 Jul 2021 07:14:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57232) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3cq5-0000w9-A6 for guix-patches@gnu.org; Wed, 14 Jul 2021 07:14:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59878) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3cq4-0000xf-K9 for guix-patches@gnu.org; Wed, 14 Jul 2021 07:14:04 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m3cq4-0001Pp-Gx for guix-patches@gnu.org; Wed, 14 Jul 2021 07:14:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49025] [PATCH v6 05/22] packages: Define this-package-input and this-package-native-input. Resent-From: Maxime Devos Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 14 Jul 2021 11:14:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49025 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49025@debbugs.gnu.org Cc: Mathieu Othacehe , Maxime Devos Received: via spool by 49025-submit@debbugs.gnu.org id=B49025.16262612125243 (code B ref 49025); Wed, 14 Jul 2021 11:14:04 +0000 Received: (at 49025) by debbugs.gnu.org; 14 Jul 2021 11:13:32 +0000 Received: from localhost ([127.0.0.1]:43153 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3cpX-0001MP-Rf for submit@debbugs.gnu.org; Wed, 14 Jul 2021 07:13:32 -0400 Received: from andre.telenet-ops.be ([195.130.132.53]:39796) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3cpN-0001Jd-40 for 49025@debbugs.gnu.org; Wed, 14 Jul 2021 07:13:22 -0400 Received: from localhost.localdomain ([188.188.219.228]) by andre.telenet-ops.be with bizsmtp id UzDG2500W4wFxCU01zDLFF; Wed, 14 Jul 2021 13:13:20 +0200 From: Maxime Devos Date: Wed, 14 Jul 2021 13:12:50 +0200 Message-Id: <20210714111307.19324-6-maximedevos@telenet.be> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210714111307.19324-1-maximedevos@telenet.be> References: <20210714111307.19324-1-maximedevos@telenet.be> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1626261200; bh=+F3V0IHIUMToVYJ2+Q+SGOqXx5CD1I8U9LvkAPCAvXY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dsPGDGLoXMmy4Yohg9W3e6U45H+ViXHbNFzaPx+Vyn1Sv1FPaEh3GV50MeR9vH0VS fMk4rKEz2MzCQZRRytZ6hG61RYdRbaU9ZQSl6HWlTdwsNwVMrwI+DvZz6J+hNEDxSG PjkFsdYK2pn0gWXZP9EmW/r2MghANQtEGG/JBqEH3FNYMUuWtbTSMBDWGbAhJBYnJ4 2JnHddtkwXyHdl0uue5kI90dmXLH3V6FAbPnMIiV6MpbOokLhI1kKfWq8fgyWcmOl5 3aKz2aCBn3PfYFrjvE/TFZ2eQnfN6fdUd6L6myEgrosfVHffRCxDna3LMizsA/yO1c YhCD/II1gHnfQ== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1626261271; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=+F3V0IHIUMToVYJ2+Q+SGOqXx5CD1I8U9LvkAPCAvXY=; b=tLRfNNUuhFsrQdcF8U4xm6Yn5NaTxGehMiDN4V08xf17fJVOnym2w8KaDxHaK+/w5S52Dd CfDrB55GP0O+IKdQOOq7OILVAxFTj0WdmzRw6LmETVdZMc6yaCov65oVttsfoq546EKbYq a7W5wwPaxNgWmpIzYw0f9PquQX8zR7nZ5bMykq4hw5sfzso3v5kRf0tQcTLCvzbIZRQTAU P4vgWqWYUBPxHdzWZc/pcF323Scu6QaEISdNpW1yEvbv9EExUEEenudMcJPvdCD+6Ee3Tg PaNeNZtqR1dVu6HZ1x7s1KzYk7OQ+IQR1AiSJIxnz/P1ZADenCKt9EqnESpk8w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1626261271; a=rsa-sha256; cv=none; b=d4/kGfc5zOmIo2n/sFvxPjY3wJxkOkaJfv6D/mk/EHbm2HZrNqg1HwNF8OI6nJybyQmDBT fvhFnEWOkzTfxQxgKnPSqZDl7LLjTr38G+mq6C5RYRl3rNb6AnsgvqTt/dCiiO4pcSSU1N sErWh5snWwOlBKH5r2GeQgYeMLFi8hrXCo/PhdlbSrGVcN9jnMeC0MSTxPEwMrDlbx9k/Q GMQZrgpED484TG6L/5cWSt4C8WfUpHpvutRgtU/z88SUjqRQJ+o0353mWNTL8mN7NEzbLN SmRvOE4eto/QvUPJZc63yO9E3XPMQ6Rx5PdsWE1qnxkFpCicVPn9yIRf7vQXkw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=dsPGDGLo; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -0.30 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b=dsPGDGLo; dmarc=fail reason="SPF not aligned (relaxed)" header.from=telenet.be (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 805E515990 X-Spam-Score: -0.30 X-Migadu-Scanner: scn0.migadu.com X-TUID: 0XMFzjJSgryM 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 3ba61b42c9..56300e6b61 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 47fc34d3ce..9814015a05 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 ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2021 Maxim Cournoyer +;;; Copyright © 2021 Maxime Devos ;;; ;;; This file is part of GNU Guix. ;;; @@ -1866,6 +1867,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