From: "Jakub Kądziołka" <kuba@kadziolka.net>
To: 42049@debbugs.gnu.org
Subject: [bug#42049] [PATCH 3/4] build-system/cargo: Add a propagated-phases argument.
Date: Thu, 25 Jun 2020 23:26:37 +0200 [thread overview]
Message-ID: <20200625212637.26099-1-kuba@kadziolka.net> (raw)
In-Reply-To: <20200625212523.25016-1-kuba@kadziolka.net>
* 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
next prev parent reply other threads:[~2020-06-25 21:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 21:25 [bug#42049] [PATCH 0/4] build-system/cargo: Propagations across the crate closure Jakub Kądziołka
2020-06-25 21:26 ` [bug#42049] [PATCH 1/4] build-system/cargo: Allow propagating inputs across CARGO-INPUTS edges Jakub Kądziołka
2020-06-25 21:26 ` [bug#42049] [PATCH 2/4] gnu: crates-io: Use propagated-inputs and propagated-native-inputs Jakub Kądziołka
2020-06-25 21:26 ` Jakub Kądziołka [this message]
2020-06-25 21:26 ` [bug#42049] [PATCH 4/4] gnu: crates-io: Use propagated-phases Jakub Kądziołka
2020-08-13 9:48 ` [bug#42049] [PATCH 0/4] build-system/cargo: Propagations across the crate closure Efraim Flashner
2020-08-13 16:16 ` Jakub Kądziołka
2020-08-14 21:26 ` Leo Famulari
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200625212637.26099-1-kuba@kadziolka.net \
--to=kuba@kadziolka.net \
--cc=42049@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).