From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id YL3eOqoW9V6XAQAA0tVLHw (envelope-from ) for ; Thu, 25 Jun 2020 21:27:06 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id WK/BNqoW9V7FEQAAbx9fmQ (envelope-from ) for ; Thu, 25 Jun 2020 21:27:06 +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 908259403CA for ; Thu, 25 Jun 2020 21:27:06 +0000 (UTC) Received: from localhost ([::1]:44116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joZOj-0002Kd-Ho for larch@yhetil.org; Thu, 25 Jun 2020 17:27:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51638) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joZOg-0002KH-AK for guix-patches@gnu.org; Thu, 25 Jun 2020 17:27:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58091) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1joZOg-0004Uh-0q for guix-patches@gnu.org; Thu, 25 Jun 2020 17:27:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1joZOf-0002qw-TQ for guix-patches@gnu.org; Thu, 25 Jun 2020 17:27:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42049] [PATCH 1/4] build-system/cargo: Allow propagating inputs across CARGO-INPUTS edges References: <20200625212523.25016-1-kuba@kadziolka.net> In-Reply-To: <20200625212523.25016-1-kuba@kadziolka.net> Resent-From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 25 Jun 2020 21:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42049 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 42049@debbugs.gnu.org Received: via spool by 42049-submit@debbugs.gnu.org id=B42049.159312039210888 (code B ref 42049); Thu, 25 Jun 2020 21:27:01 +0000 Received: (at 42049) by debbugs.gnu.org; 25 Jun 2020 21:26:32 +0000 Received: from localhost ([127.0.0.1]:41395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1joZOC-0002pX-8h for submit@debbugs.gnu.org; Thu, 25 Jun 2020 17:26:32 -0400 Received: from pat.zlotemysli.pl ([37.59.186.212]:49904) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1joZOA-0002pO-96 for 42049@debbugs.gnu.org; Thu, 25 Jun 2020 17:26:30 -0400 Received: (qmail 32404 invoked by uid 1009); 25 Jun 2020 23:26:28 +0200 Received: from 188.123.215.55 (kuba@kadziolka.net@188.123.215.55) by pat.zlotemysli.pl (envelope-from , uid 1002) with qmail-scanner-2.08st (clamdscan: 0.98.6/25853. spamassassin: 3.4.0. perlscan: 2.08st. Clear:RC:1(188.123.215.55):. Processed in 0.017913 secs); 25 Jun 2020 21:26:28 -0000 Received: from unknown (HELO localhost.localdomain) (kuba@kadziolka.net@188.123.215.55) by pat.zlotemysli.pl with AES256-SHA encrypted SMTP; 25 Jun 2020 23:26:28 +0200 From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Date: Thu, 25 Jun 2020 23:26:27 +0200 Message-Id: <20200625212627.25622-1-kuba@kadziolka.net> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Qmailux-2.08st: added fake Content-Type header Content-Type: text/plain X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -1.0 (-) 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-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=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-Spam-Score: 2.49 X-TUID: SIJdfL9ySYVk * guix/build-system/cargo.scm (package-propagated-native-inputs): New procedure. (expand-crate-sources): Take crate closure instead of input lists. (lower): Expand host-inputs and build-inputs to include inputs from the crate closure. --- guix/build-system/cargo.scm | 59 +++++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 22 deletions(-) diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm index 6c8edf6bac..3f518343ec 100644 --- a/guix/build-system/cargo.scm +++ b/guix/build-system/cargo.scm @@ -143,6 +143,12 @@ to NAME and VERSION." cargo-development-inputs) (package-arguments p))) +(define (package-propagated-native-inputs p) + (apply + (lambda* (#:key (propagated-native-inputs '()) #:allow-other-keys) + propagated-native-inputs) + (package-arguments p))) + (define (crate-closure inputs) "Return the closure of INPUTS when considering the 'cargo-inputs' and 'cargod-dev-deps' edges. Omit duplicate inputs, except for those @@ -182,9 +188,8 @@ do not extract the conventional inputs)." ((input rest ...) (loop rest (cons input result) propagated first? seen))))) -(define (expand-crate-sources cargo-inputs cargo-development-inputs) - "Extract all transitive sources for CARGO-INPUTS and CARGO-DEVELOPMENT-INPUTS -along their 'cargo-inputs' edges. +(define (expand-crate-sources crate-closure) + "Extract all sources for the transitive cargo inputs provided in CRATE-CLOSURE. Cargo requires all transitive crate dependencies' sources to be available in its index, even if they are optional (this is so it can generate @@ -236,40 +241,50 @@ any dependent crates. This can be a benefits: (list label (package-source p))) ((label input) (list label input))) - (crate-closure (append cargo-inputs cargo-development-inputs)))) + crate-closure)) (define* (lower name #:key source inputs native-inputs outputs system target (rust (default-rust)) (cargo-inputs '()) (cargo-development-inputs '()) + (propagated-native-inputs '()) #:allow-other-keys #:rest arguments) "Return a bag for NAME." (define private-keywords '(#:source #:target #:rust #:inputs #:native-inputs #:outputs - #:cargo-inputs #:cargo-development-inputs)) + #:cargo-inputs #:cargo-development-inputs #:propagated-native-inputs)) (and (not target) ;; TODO: support cross-compilation - (bag - (name name) - (system system) - (target target) - (host-inputs `(,@(if source - `(("source" ,source)) - '()) - ,@inputs + (let ((closure (crate-closure + (append cargo-inputs cargo-development-inputs)))) + (bag + (name name) + (system system) + (target target) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@inputs + ,@(append-map + (compose package-propagated-inputs second) + closure) - ;; Keep the standard inputs of 'gnu-build-system' - ,@(standard-packages))) - (build-inputs `(("cargo" ,rust "cargo") - ("rustc" ,rust) - ,@(expand-crate-sources cargo-inputs cargo-development-inputs) - ,@native-inputs)) - (outputs outputs) - (build cargo-build) - (arguments (strip-keyword-arguments private-keywords arguments))))) + ;; Keep the standard inputs of 'gnu-build-system' + ,@(standard-packages))) + (build-inputs `(("cargo" ,rust "cargo") + ("rustc" ,rust) + ,@(expand-crate-sources closure) + ,@(append-map + (compose package-propagated-native-inputs second) + closure) + ,@propagated-native-inputs + ,@native-inputs)) + (outputs outputs) + (build cargo-build) + (arguments (strip-keyword-arguments private-keywords arguments)))))) (define cargo-build-system (build-system -- 2.26.2