From patchwork Thu Jun 25 21:26:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Maja_K=C4=85dzio=C5=82ka?= X-Patchwork-Id: 22870 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A17F627BBE3; Thu, 25 Jun 2020 22:27:08 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id F2F5B27BBE1 for ; Thu, 25 Jun 2020 22:27:07 +0100 (BST) Received: from localhost ([::1]:44116 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joZOl-0002Kd-HY for patchwork@mira.cbaines.net; Thu, 25 Jun 2020 17:27:07 -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?b?S8SFZHppb8WCa2E=?= 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?b?S8SFZHppb8WCa2E=?= 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 X-Qmailux-2.08st: added fake Content-Type header 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * 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