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 /5rBItmvZGFeKgEAgWs5BA (envelope-from ) for ; Mon, 11 Oct 2021 23:42:49 +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 kGXPHNmvZGFYdgAA1q6Kng (envelope-from ) for ; Mon, 11 Oct 2021 21:42:49 +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 01693E2CA for ; Mon, 11 Oct 2021 23:42:49 +0200 (CEST) Received: from localhost ([::1]:39796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ma34K-0001Iz-4n for larch@yhetil.org; Mon, 11 Oct 2021 17:42:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ma30g-0006aE-Ow for guix-patches@gnu.org; Mon, 11 Oct 2021 17:39:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49607) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ma30f-0004pd-Lu for guix-patches@gnu.org; Mon, 11 Oct 2021 17:39:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ma30f-0001PE-Jq for guix-patches@gnu.org; Mon, 11 Oct 2021 17:39:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50960] [PATCH v2 01/11] packages: Add 'package-development-inputs'. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 11 Oct 2021 21:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50960 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50960@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= Received: via spool by 50960-submit@debbugs.gnu.org id=B50960.16339883085231 (code B ref 50960); Mon, 11 Oct 2021 21:39:01 +0000 Received: (at 50960) by debbugs.gnu.org; 11 Oct 2021 21:38:28 +0000 Received: from localhost ([127.0.0.1]:32888 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ma308-0001MJ-5y for submit@debbugs.gnu.org; Mon, 11 Oct 2021 17:38:28 -0400 Received: from eggs.gnu.org ([209.51.188.92]:45444) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ma307-0001Lx-Dy for 50960@debbugs.gnu.org; Mon, 11 Oct 2021 17:38:27 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:40564) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ma301-0004VQ-P9; Mon, 11 Oct 2021 17:38:21 -0400 Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:53321 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ma301-0007Y0-Fk; Mon, 11 Oct 2021 17:38:21 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Mon, 11 Oct 2021 23:37:59 +0200 Message-Id: <20211011213809.17482-2-ludo@gnu.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011213809.17482-1-ludo@gnu.org> References: <20211002102116.27726-1-ludo@gnu.org> <20211011213809.17482-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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=1633988569; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: 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; bh=Hv6IXCsb1DS8yYgqfMdLgMbG10744tRxfj2dfRycG1g=; b=GCJ1mFEcQdcgVR0xJGVBtaGDmleEdwv3COXaxW6E65wC2Hv58plF4lyoAukSq8qNwymrJj 3JpNPk3UhUBovfGAI61l/gJEdwq4G46h5LaYYa4HZwFE0BPW71qNYOOoG3+FOd3MtCR1ts ipaUlVzNH3AClHNh/6uJZEshsyyoStQKGIPi3pbvfHh2gBrvMm3iCGzAl2YlpNl181clQ0 hnmfpZXIao966ncmiJVyA4mtowNkYfJWgsUSOIvJeNpNjoBA00fz18ZvjKkXzVXykeMI2F 2oMrL+JoR2fZdM8YLG3ifUoJFcCKxMkgBSkIYZq7NO7S2hn9V4+DXZS0YjXXsg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633988569; a=rsa-sha256; cv=none; b=kCOm29sCrTLnyVWTehwXlgCNmp8TTXm36k1MoenRrITsT8bMPu0S4tcTPQOg8gd8MVXwos VgmzNLsI5bMO+ioCdpTjx+RXUuJ8rHjCpurykgnJ7fhebez7UT8U38CuBg/rGgBISxWjJE J0qWefGXFWGnGYzCkrc8a6m0HfKSycLqCrAdykcH6Md06Qz5F334TtxlTOdskJ6kvYu1Xm bmLAKxM0x4KCwcR9+Zc+9jCfOb+HXSpJzDT+dUHWGI7GZz1OOrQY3ZKgApEAK+/Asq9AGr LXKMzb5v8iweEXVK1RDxBiAWyysP4GvGZSKRWt63WC28NIXszsdyzbclUW31cA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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: 2.08 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; 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: 01693E2CA X-Spam-Score: 2.08 X-Migadu-Scanner: scn0.migadu.com X-TUID: 03aR8tAHv/IX * guix/packages.scm (package-development-inputs): New procedure. * guix/scripts/environment.scm (package-environment-inputs): Use it. * tests/packages.scm ("package-development-inputs") ("package-development-inputs, cross-compilation"): New tests. * doc/guix.texi (package Reference): Document it. --- doc/guix.texi | 41 ++++++++++++++++++++++++++++++++++++ guix/packages.scm | 10 +++++++++ guix/scripts/environment.scm | 2 +- tests/packages.scm | 14 ++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index a72a726b54..49399e792b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6847,6 +6847,47 @@ cross-compiling: It is an error to refer to @code{this-package} outside a package definition. @end deffn +@cindex development inputs, of a package +@cindex implicit inputs, of a package +Sometimes you will want to obtain the list of inputs needed to +@emph{develop} a package---all the inputs that are visible when the +package is compiled. This is what the @code{package-development-inputs} +procedure returns. + +@deffn {Scheme Procedure} package-development-inputs @var{package} @ + [@var{system}] [#:target #f] +Return the list of inputs required by @var{package} for development +purposes on @var{system}. When @var{target} is true, return the inputs +needed to cross-compile @var{package} from @var{system} to +@var{triplet}, where @var{triplet} is a triplet such as +@code{"aarch64-linux-gnu"}. + +Note that the result includes both explicit inputs and implicit +inputs---inputs automatically added by the build system (@pxref{Build +Systems}). Let us take the @code{hello} package to illustrate that: + +@lisp +(use-modules (gnu packages base) (guix packages)) + +hello +@result{} # + +(package-direct-inputs hello) +@result{} () + +(package-development-inputs hello) +@result{} (("source" @dots{}) ("tar" #) @dots{}) +@end lisp + +In this example, @code{package-direct-inputs} returns the empty list, +because @code{hello} has zero explicit dependencies. Conversely, +@code{package-development-inputs} includes inputs implicitly added by +@code{gnu-build-system} that are required to build @code{hello}: tar, +gzip, GCC, libc, Bash, and more. To visualize it, @command{guix graph +hello} would show you explicit inputs, whereas @command{guix graph -t +bag hello} would include implicit inputs (@pxref{Invoking guix graph}). +@end deffn + Because packages are regular Scheme objects that capture a complete dependency graph and associated build procedures, it is often useful to write procedures that take a package and return a modified version diff --git a/guix/packages.scm b/guix/packages.scm index 8c3a0b0b7b..43e0130793 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -153,6 +153,7 @@ (define-module (guix packages) bag-transitive-host-inputs bag-transitive-build-inputs bag-transitive-target-inputs + package-development-inputs package-closure default-guile @@ -1070,6 +1071,15 @@ (define (bag-transitive-target-inputs bag) (%current-system (bag-system bag))) (transitive-inputs (bag-target-inputs bag)))) +(define* (package-development-inputs package + #:optional (system (%current-system)) + #:key target) + "Return the list of inputs required by PACKAGE for development purposes on +SYSTEM. When TARGET is true, return the inputs needed to cross-compile +PACKAGE from SYSTEM to TRIPLET, where TRIPLET is a triplet such as +\"aarch64-linux-gnu\"." + (bag-transitive-inputs (package->bag package system target))) + (define* (package-closure packages #:key (system (%current-system))) "Return the closure of PACKAGES on SYSTEM--i.e., PACKAGES and the list of packages they depend on, recursively." diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm index 6958bd6238..d555969b27 100644 --- a/guix/scripts/environment.scm +++ b/guix/scripts/environment.scm @@ -82,7 +82,7 @@ (define (package-environment-inputs package) packages for PACKAGE." ;; Remove non-package inputs such as origin records. (filter-map input->manifest-entry - (bag-transitive-inputs (package->bag package)))) + (package-development-inputs package system))) (define (show-help) (display (G_ "Usage: guix environment [OPTION]... PACKAGE... [-- COMMAND...] diff --git a/tests/packages.scm b/tests/packages.scm index 3756877270..266b5aeb7a 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -353,6 +353,20 @@ (define read-at (package-transitive-supported-systems d) (package-transitive-supported-systems e)))) +(test-assert "package-development-inputs" + ;; Note: Due to propagated inputs, 'package-development-inputs' returns a + ;; couple more inputs, such as 'linux-libre-headers'. + (lset<= equal? + `(("source" ,(package-source hello)) ,@(standard-packages)) + (package-development-inputs hello))) + +(test-assert "package-development-inputs, cross-compilation" + (lset<= equal? + `(("source" ,(package-source hello)) + ,@(standard-cross-packages "mips64el-linux-gnu" 'host) + ,@(standard-cross-packages "mips64el-linux-gnu" 'target)) + (package-development-inputs hello #:target "mips64el-linux-gnu"))) + (test-assert "package-closure" (let-syntax ((dummy-package/no-implicit (syntax-rules () -- 2.33.0