From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id mOd5KWN9x2BhbQAAgWs5BA (envelope-from ) for ; Mon, 14 Jun 2021 18:01:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 8vTEJGN9x2B6NQAAB5/wlQ (envelope-from ) for ; Mon, 14 Jun 2021 16:01:39 +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 6E17C34D4C for ; Mon, 14 Jun 2021 18:01:38 +0200 (CEST) Received: from localhost ([::1]:39250 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsp1t-0001Uk-ED for larch@yhetil.org; Mon, 14 Jun 2021 12:01:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsof5-0008LK-FV for guix-patches@gnu.org; Mon, 14 Jun 2021 11:38:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36000) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsof5-00077k-5f for guix-patches@gnu.org; Mon, 14 Jun 2021 11:38:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lsof5-0004Dp-47 for guix-patches@gnu.org; Mon, 14 Jun 2021 11:38:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49025] [PATCH core-updates 03/37] 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: Mon, 14 Jun 2021 15:38:03 +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 Received: via spool by 49025-submit@debbugs.gnu.org id=B49025.162368504416052 (code B ref 49025); Mon, 14 Jun 2021 15:38:03 +0000 Received: (at 49025) by debbugs.gnu.org; 14 Jun 2021 15:37:24 +0000 Received: from localhost ([127.0.0.1]:47507 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsoeR-0004Aq-G0 for submit@debbugs.gnu.org; Mon, 14 Jun 2021 11:37:23 -0400 Received: from albert.telenet-ops.be ([195.130.137.90]:37390) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsoeP-0004Ah-78 for 49025@debbugs.gnu.org; Mon, 14 Jun 2021 11:37:21 -0400 Received: from butterfly.local ([IPv6:2a02:1811:8c09:9d00:aaf1:9810:a0b8:a55d]) by albert.telenet-ops.be with bizsmtp id H3dK2500Q0mfAB4063dL7F; Mon, 14 Jun 2021 17:37:20 +0200 Message-ID: From: Maxime Devos Date: Mon, 14 Jun 2021 17:37:19 +0200 In-Reply-To: References: Content-Type: multipart/mixed; boundary="=-aqdcE9fvlHxGDfwQgr/Y" User-Agent: Evolution 3.34.2 MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telenet.be; s=r21; t=1623685040; bh=gxbilsOjCrADWcUWiU6E8vOBaNo7+d1LXmx/BF1mapI=; h=Subject:From:To:Date:In-Reply-To:References; b=Xk/Kh/fopx4WO50aJ3mMeBos+tfC8pnZWRG2lTsU5dXfMefTKyFP0JpDDrKmCfSga qIOgxaRpNLWHX6hTyDtdIXTsL8BLp2Eq1JNJ8+imjkaSZRujDuz6oO7oBCa0nfDTUf 5tU9t6UvSODXbJIscuzEVtlyKp3RUgU+otcurQ5SLqBh8FkSgwgyuDUXvyhrZZYZKb 1uunDYG/9kiwBMj2PeMTGmkHTswO1Bdfmm8cV8wfuRbH6ucQ8XRMD/imoZ8kHUMoMX fvrXV0n8+5h6W7a9zwxURAm9uavAJl+jghNbQS7ulgwLC0pEVvv10ir2B5G3reYoX1 ZIFht05lm5vDw== 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=1623686498; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: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=gxbilsOjCrADWcUWiU6E8vOBaNo7+d1LXmx/BF1mapI=; b=jTNRyxAg0VxrbhiSM2/QWyYuEX3IuY9ORwnam5IDvNWAhqo7DAm8txuiDjfCAepRVrvDkR zzkxLSkEnCKEAMYRzXtZRUgff3ejU6Udm3Ur7QfNL3VFZtgwiBZPOU5yV/gxYPMS8rP5IV 0zpK7z7bFP0tJcfqLQldL85Uiz4Xj37AHDPu4d9q5xYL2wDJidKufWuPwaddO0yJx9zRHp DeitFm1wwvmDk9NkLIkKfMuzrNjeH0MRqZ8YdLM5XGIaqZDC3LrckgjvF6VvvOUeHOKdfZ r2I7KdGYOCtAo9EwP4Kld33JpWQxC07/9rJJCH9SW2v6oszJVo0b97Mr8XKhyA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1623686498; a=rsa-sha256; cv=none; b=tt4d0DoNMA4O5WN5VZBmD3pdkc2yxG67QTMjEWh9ad/mpgTeBrJmRIVEqGYElvaUt8pYf2 LvhG72bXJSvRvLpsB8p2m+oTg7xKgRTxqJBV+KmObvzqagzhSIduk1BbyLlc4p8WWxxtMa 7mBvBb9b7hpciqGM5UOKkYtJSujxJ9sOXiND3/waK9EA96pA9nNq1+bhGN5pm+MUyQ7rN2 /amCsZeRUnbViAtIQ9TwWEohGpA8aYPWxaDUEuXTldwX1Wk5fkQeVkan2eCEp1TB6jHpxi /dhkMNBlfJ53kK4OkUlN31OvBGgnVrhmml3hxl2VWD/egSLk5LZuYyxDs7jVeA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b="Xk/Kh/fo"; 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: -1.33 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=telenet.be header.s=r21 header.b="Xk/Kh/fo"; 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: 6E17C34D4C X-Spam-Score: -1.33 X-Migadu-Scanner: scn0.migadu.com X-TUID: y1j3+DzssGoH --=-aqdcE9fvlHxGDfwQgr/Y Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit 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(+) --=-aqdcE9fvlHxGDfwQgr/Y Content-Disposition: attachment; filename="0003-packages-Define-this-package-input-and-this-package-.patch" Content-Transfer-Encoding: 8bit Content-Type: text/x-patch; name="0003-packages-Define-this-package-input-and-this-package-.patch"; charset="UTF-8" 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 ;;; Copyright © 2018 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2021 Maxim Cournoyer +;;; Copyright © 2021 Maxime Devos ;;; ;;; 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: --=-aqdcE9fvlHxGDfwQgr/Y--