From: "Jakub Kądziołka" <kuba@kadziolka.net>
To: 42049@debbugs.gnu.org
Subject: [bug#42049] [PATCH 1/4] build-system/cargo: Allow propagating inputs across CARGO-INPUTS edges
Date: Thu, 25 Jun 2020 23:26:27 +0200 [thread overview]
Message-ID: <20200625212627.25622-1-kuba@kadziolka.net> (raw)
In-Reply-To: <20200625212523.25016-1-kuba@kadziolka.net>
* 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
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 ` Jakub Kądziołka [this message]
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 ` [bug#42049] [PATCH 3/4] build-system/cargo: Add a propagated-phases argument Jakub Kądziołka
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=20200625212627.25622-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).