guix_mirror_bot pushed a commit to branch rust-team
in repository guix.
commit 058914e135ebbc453b5f3c42caa1ad7ff625466c
Author: Danny Milosavljevic <[email protected]>
AuthorDate: Mon Jul 20 02:47:34 2026 +0200
build-system/cargo: Reuse more build outputs in install phase.
* guix/build/cargo-build-system.scm (build): Build things equal to later
cargo install.
(install): Make sure it doesn't try to change the lock file that the
build phase used.
Closes: guix/guix#10059
Change-Id: I98208eb26ef532366ef3ceb23b9e2b2aa297a6c5
---
guix/build/cargo-build-system.scm | 38 +++++++++++++++++++++++++++-----------
1 file changed, 27 insertions(+), 11 deletions(-)
diff --git a/guix/build/cargo-build-system.scm
b/guix/build/cargo-build-system.scm
index 323c71a8a57..8253760e9b9 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -314,18 +314,34 @@ directory = '" vendor-dir "'") port)
(skip-build? #f)
(features '())
(cargo-build-flags '("--release"))
+ (cargo-install-paths '())
#:allow-other-keys)
"Build a given Cargo package."
- (or skip-build?
- (apply invoke
- `("cargo" "build" "--offline"
- ,@(if parallel-build?
- (list "-j" (number->string (parallel-job-count)))
- (list "-j" "1"))
- ,@(if (null? features)
- '()
- `("--features" ,(string-join features)))
- ,@cargo-build-flags))))
+ (define common-arguments
+ `("--offline"
+ ,@(if parallel-build?
+ (list "-j" (number->string (parallel-job-count)))
+ (list "-j" "1"))
+ ,@(if (member "--release" cargo-build-flags)
+ '()
+ '("--release"))
+ ,@(if (null? features)
+ '()
+ `("--features" ,(string-join features)))
+ ,@cargo-build-flags))
+
+ (unless skip-build?
+ (if (null? cargo-install-paths)
+ (apply invoke "cargo" "build" common-arguments)
+ (for-each
+ (lambda (path)
+ (apply invoke
+ `("cargo" "build"
+ "--bins"
+ "--manifest-path"
+ ,(in-vicinity path "Cargo.toml")
+ ,@common-arguments)))
+ cargo-install-paths))))
(define* (check #:key
parallel-build?
@@ -461,7 +477,7 @@ directory = '" vendor-dir "'") port)
(not (has-executable-target? features)))
(for-each
(lambda (path)
- (invoke "cargo" "install" "--offline" "--no-track"
+ (invoke "cargo" "install" "--offline" "--locked" "--no-track"
"--path" path "--root" out
"--features" (string-join features)))
(if (null? cargo-install-paths)