mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2025-01-23 02:36:40 +01:00
build/cargo: Honor #:parallel-build? and #:parallel-tests? arguments.
* guix/build-system/cargo.scm (cargo-build): Add #:parallel-build? and #:parallel-tests? arguments. (cargo-cross-build): Likewise. * guix/build/cargo-build-system.scm (build): Honor them. (check): Likewise. Change-Id: Idbee7aa3a6a7cd0fc222082837390b83cc8e8c07 Signed-off-by: Efraim Flashner <efraim@flashner.co.il>
This commit is contained in:
parent
e8ef2371e9
commit
9947252442
2 changed files with 29 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
||||||
;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
|
;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
|
||||||
;;; Copyright © 2021, 2024 Efraim Flashner <efraim@flashner.co.il>
|
;;; Copyright © 2021, 2024 Efraim Flashner <efraim@flashner.co.il>
|
||||||
;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
|
;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
|
||||||
|
;;; Copyright © 2024 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -96,6 +97,8 @@ (define* (cargo-build name inputs
|
||||||
(cargo-package-flags ''("--no-metadata" "--no-verify"))
|
(cargo-package-flags ''("--no-metadata" "--no-verify"))
|
||||||
(features ''())
|
(features ''())
|
||||||
(skip-build? #f)
|
(skip-build? #f)
|
||||||
|
(parallel-build? #t)
|
||||||
|
(parallel-tests? #t)
|
||||||
(install-source? #t)
|
(install-source? #t)
|
||||||
(phases '%standard-phases)
|
(phases '%standard-phases)
|
||||||
(outputs '("out"))
|
(outputs '("out"))
|
||||||
|
@ -123,6 +126,8 @@ (define builder
|
||||||
#:cargo-target #$(cargo-triplet system)
|
#:cargo-target #$(cargo-triplet system)
|
||||||
#:features #$(sexp->gexp features)
|
#:features #$(sexp->gexp features)
|
||||||
#:skip-build? #$skip-build?
|
#:skip-build? #$skip-build?
|
||||||
|
#:parallel-build? #$parallel-build?
|
||||||
|
#:parallel-tests? #$parallel-tests?
|
||||||
#:install-source? #$install-source?
|
#:install-source? #$install-source?
|
||||||
#:tests? #$(and tests? (not skip-build?))
|
#:tests? #$(and tests? (not skip-build?))
|
||||||
#:phases #$(if (pair? phases)
|
#:phases #$(if (pair? phases)
|
||||||
|
@ -153,6 +158,8 @@ (define* (cargo-cross-build name
|
||||||
(cargo-target (cargo-triplet (or target system)))
|
(cargo-target (cargo-triplet (or target system)))
|
||||||
(features ''())
|
(features ''())
|
||||||
(skip-build? #f)
|
(skip-build? #f)
|
||||||
|
(parallel-build? #t)
|
||||||
|
(parallel-tests? #t)
|
||||||
(install-source? (not (target-mingw? target)))
|
(install-source? (not (target-mingw? target)))
|
||||||
(phases '%standard-phases)
|
(phases '%standard-phases)
|
||||||
(outputs '("out"))
|
(outputs '("out"))
|
||||||
|
@ -182,6 +189,8 @@ (define builder
|
||||||
#:cargo-target #$(cargo-triplet (or target system))
|
#:cargo-target #$(cargo-triplet (or target system))
|
||||||
#:features #$(sexp->gexp features)
|
#:features #$(sexp->gexp features)
|
||||||
#:skip-build? #$skip-build?
|
#:skip-build? #$skip-build?
|
||||||
|
#:parallel-build? #$parallel-build?
|
||||||
|
#:parallel-tests? #$parallel-tests?
|
||||||
#:install-source? #$install-source?
|
#:install-source? #$install-source?
|
||||||
#:tests? #$(and tests? (not skip-build?))
|
#:tests? #$(and tests? (not skip-build?))
|
||||||
#:phases #$(if (pair? phases)
|
#:phases #$(if (pair? phases)
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
;;; Copyright © 2019-2024 Efraim Flashner <efraim@flashner.co.il>
|
;;; Copyright © 2019-2024 Efraim Flashner <efraim@flashner.co.il>
|
||||||
;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
|
;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
|
||||||
;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
|
;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
|
||||||
|
;;; Copyright © 2024 Maxim Cournoyer <maxim.cournoyer@gmail.com>
|
||||||
;;;
|
;;;
|
||||||
;;; This file is part of GNU Guix.
|
;;; This file is part of GNU Guix.
|
||||||
;;;
|
;;;
|
||||||
|
@ -239,19 +240,35 @@ (define* (build #:key
|
||||||
(or skip-build?
|
(or skip-build?
|
||||||
(apply invoke
|
(apply invoke
|
||||||
`("cargo" "build"
|
`("cargo" "build"
|
||||||
|
,@(if parallel-build?
|
||||||
|
(list "-j" (number->string (parallel-job-count)))
|
||||||
|
(list "-j" "1"))
|
||||||
,@(if (null? features)
|
,@(if (null? features)
|
||||||
'()
|
'()
|
||||||
`("--features" ,(string-join features)))
|
`("--features" ,(string-join features)))
|
||||||
,@cargo-build-flags))))
|
,@cargo-build-flags))))
|
||||||
|
|
||||||
(define* (check #:key
|
(define* (check #:key
|
||||||
|
parallel-build?
|
||||||
|
parallel-tests?
|
||||||
tests?
|
tests?
|
||||||
(cargo-test-flags '("--release"))
|
(cargo-test-flags '("--release"))
|
||||||
#:allow-other-keys)
|
#:allow-other-keys)
|
||||||
"Run tests for a given Cargo package."
|
"Run tests for a given Cargo package."
|
||||||
(if tests?
|
(when tests?
|
||||||
(apply invoke "cargo" "test" cargo-test-flags)
|
(apply invoke
|
||||||
#t))
|
`("cargo" "test"
|
||||||
|
,@(if parallel-build?
|
||||||
|
(list "-j" (number->string (parallel-job-count)))
|
||||||
|
(list "-j" "1"))
|
||||||
|
,@cargo-test-flags
|
||||||
|
,@(if (member "--" cargo-test-flags)
|
||||||
|
'()
|
||||||
|
'("--"))
|
||||||
|
,@(if parallel-tests?
|
||||||
|
(list "--test-threads"
|
||||||
|
(number->string (parallel-job-count)))
|
||||||
|
(list "--test-threads" "1"))))))
|
||||||
|
|
||||||
(define* (package #:key
|
(define* (package #:key
|
||||||
source
|
source
|
||||||
|
|
Loading…
Reference in a new issue