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 ms11 with LMTPS id 0KTFAbgW9V5gfQAA0tVLHw (envelope-from ) for ; Thu, 25 Jun 2020 21:27:20 +0000 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 IPJZObcW9V5tZgAA1q6Kng (envelope-from ) for ; Thu, 25 Jun 2020 21:27:19 +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 AD91094053E for ; Thu, 25 Jun 2020 21:27:19 +0000 (UTC) Received: from localhost ([::1]:44748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1joZOw-0002b7-MZ for larch@yhetil.org; Thu, 25 Jun 2020 17:27:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1joZOh-0002KU-3i for guix-patches@gnu.org; Thu, 25 Jun 2020 17:27:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58093) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1joZOg-0004Ux-Pm 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 1joZOg-0002rB-ML for guix-patches@gnu.org; Thu, 25 Jun 2020 17:27:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42049] [PATCH 3/4] build-system/cargo: Add a propagated-phases argument. 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:02 +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.159312040110924 (code B ref 42049); Thu, 25 Jun 2020 21:27:02 +0000 Received: (at 42049) by debbugs.gnu.org; 25 Jun 2020 21:26:41 +0000 Received: from localhost ([127.0.0.1]:41401 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1joZOL-0002q6-5F for submit@debbugs.gnu.org; Thu, 25 Jun 2020 17:26:41 -0400 Received: from pat.zlotemysli.pl ([37.59.186.212]:49924) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1joZOJ-0002py-E8 for 42049@debbugs.gnu.org; Thu, 25 Jun 2020 17:26:39 -0400 Received: (qmail 32536 invoked by uid 1009); 25 Jun 2020 23:26:38 +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.009546 secs); 25 Jun 2020 21:26:38 -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:38 +0200 From: Jakub =?UTF-8?Q?K=C4=85dzio=C5=82ka?= Date: Thu, 25 Jun 2020 23:26:37 +0200 Message-Id: <20200625212637.26099-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: KTNlEpRB8LSx * guix/build-system/cargo.scm (package-propagated-phases, add-phases): New procedures. (lower): Collect phases from the crate closure. --- guix/build-system/cargo.scm | 39 +++++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/guix/build-system/cargo.scm b/guix/build-system/cargo.scm index 3f518343ec..d3ec97f7fd 100644 --- a/guix/build-system/cargo.scm +++ b/guix/build-system/cargo.scm @@ -149,6 +149,12 @@ to NAME and VERSION." propagated-native-inputs) (package-arguments p))) +(define (package-propagated-phases p) + (apply + (lambda* (#:key (propagated-phases '()) #:allow-other-keys) + propagated-phases) + (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 @@ -243,23 +249,43 @@ any dependent crates. This can be a benefits: (list label input))) crate-closure)) +(define (add-phases propagated-phases base-phases) + ;; TODO(rebuild-rust): This could be simpler if avoiding rebuilds wasn't a goal. + (if (null? propagated-phases) + base-phases + (let ((phase-list `(modify-phases %standard-phases ,@propagated-phases))) + (if base-phases + `(let ((%standard-phases ,phase-list)) ,base-phases) + phase-list)))) + (define* (lower name - #:key source inputs native-inputs outputs system target + #:key source inputs native-inputs outputs system target phases (rust (default-rust)) (cargo-inputs '()) (cargo-development-inputs '()) (propagated-native-inputs '()) + (propagated-phases '()) #:allow-other-keys #:rest arguments) "Return a bag for NAME." (define private-keywords '(#:source #:target #:rust #:inputs #:native-inputs #:outputs + #:phases #:propagated-phases #:cargo-inputs #:cargo-development-inputs #:propagated-native-inputs)) (and (not target) ;; TODO: support cross-compilation - (let ((closure (crate-closure - (append cargo-inputs cargo-development-inputs)))) + (let* ((closure (crate-closure + (append cargo-inputs cargo-development-inputs))) + (closure-phases + (append-map + (compose package-propagated-phases second) + ;; Make sure the leaves of the dependency graph come first, + ;; such that their dependents may refer to the names of + ;; the phases + (reverse closure))) + (closure-phases (append closure-phases propagated-phases)) + (phases (add-phases closure-phases phases))) (bag (name name) (system system) @@ -284,7 +310,12 @@ any dependent crates. This can be a benefits: ,@native-inputs)) (outputs outputs) (build cargo-build) - (arguments (strip-keyword-arguments private-keywords arguments)))))) + (arguments + (let ((provided-arguments + (strip-keyword-arguments private-keywords arguments))) + (if phases + (cons* #:phases phases provided-arguments) + provided-arguments))))))) (define cargo-build-system (build-system -- 2.26.2