[bug#77093,rust-team,v3,04/17] build-system: cargo: Support installing Cargo workspace.
Commit Message
*guix/build-system/cargo.scm (cargo-build,cargo-cross-build)
[#:cargo-install-paths]: New argument.
* guix/build/cargo-build-system.scm (install): Use it.
* doc/guix.texi (Build Systems)[cargo-build-system]: Document it.
Change-Id: I74ed1972a5716da05afeac8edb2b0e4b6834bf40
---
doc/guix.texi | 5 ++++-
guix/build-system/cargo.scm | 4 ++++
guix/build/cargo-build-system.scm | 17 +++++++++++++----
3 files changed, 21 insertions(+), 5 deletions(-)
@@ -9369,7 +9369,10 @@ Build Systems
library crates to package in the @code{package} phase. Specified crates are
packaged from left to right, in case there's dependency among them. For
example, specifying @code{''("pcre2-sys" "pcre2")} will package
-@code{"pcre2-sys"} first and then @code{"pcre2"}.
+@code{"pcre2-sys"} first and then @code{"pcre2"}. Parameter
+@code{#:cargo-install-paths} (default: @code{''()}) allows specifying paths of
+binary crates to install in the @code{install} phase, @code{''("crates/atuin")},
+for example.
@end defvar
@defvar chicken-build-system
@@ -96,6 +96,7 @@ (define* (cargo-build name inputs
(cargo-test-flags ''())
(cargo-package-crates ''())
(cargo-package-flags ''("--no-metadata" "--no-verify"))
+ (cargo-install-paths ''())
(features ''())
(skip-build? #f)
(parallel-build? #t)
@@ -125,6 +126,7 @@ (define* (cargo-build name inputs
#:cargo-test-flags #$(sexp->gexp cargo-test-flags)
#:cargo-package-crates #$(sexp->gexp cargo-package-crates)
#:cargo-package-flags #$(sexp->gexp cargo-package-flags)
+ #:cargo-install-paths #$(sexp->gexp cargo-install-paths)
#:cargo-target #$(cargo-triplet system)
#:features #$(sexp->gexp features)
#:skip-build? #$skip-build?
@@ -158,6 +160,7 @@ (define* (cargo-cross-build name
(cargo-test-flags ''())
(cargo-package-crates ''())
(cargo-package-flags ''("--no-metadata" "--no-verify"))
+ (cargo-install-paths ''())
(cargo-target (cargo-triplet (or target system)))
(features ''())
(skip-build? #f)
@@ -190,6 +193,7 @@ (define* (cargo-cross-build name
#:cargo-test-flags #$(sexp->gexp cargo-test-flags)
#:cargo-package-crates #$(sexp->gexp cargo-package-crates)
#:cargo-package-flags #$(sexp->gexp cargo-package-flags)
+ #:cargo-install-paths #$(sexp->gexp cargo-install-paths)
#:cargo-target #$(cargo-triplet (or target system))
#:features #$(sexp->gexp features)
#:skip-build? #$skip-build?
@@ -377,6 +377,7 @@ (define* (install #:key
skip-build?
install-source?
features
+ (cargo-install-paths '())
#:allow-other-keys)
"Install a given Cargo package."
(let* ((out (assoc-ref outputs "out"))
@@ -391,10 +392,18 @@ (define* (install #:key
;; Only install crates which include binary targets,
;; otherwise cargo will raise an error.
(or skip-build?
- (not (has-executable-target?))
- (invoke "cargo" "install" "--offline" "--no-track"
- "--path" "." "--root" out
- "--features" (string-join features)))
+ ;; NOTE: Cargo workspace installation support:
+ ;; #:skip-build? #f + #:cargo-install-paths.
+ (and (null? cargo-install-paths)
+ (not (has-executable-target?)))
+ (for-each
+ (lambda (path)
+ (invoke "cargo" "install" "--offline" "--no-track"
+ "--path" path "--root" out
+ "--features" (string-join features)))
+ (if (null? cargo-install-paths)
+ '(".")
+ cargo-install-paths)))
(when install-source?
;; Install crate tarballs and unpacked sources for later use.