mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2024-11-16 19:57:39 -05:00
utils: Export 'parallel-job-count'.
* guix/build/utils.scm (parallel-job-count): New procedure. * guix/build/gnu-build-system.scm (%parallel-job-count): Remove. (build, check): Use 'parallel-job-count' instead.
This commit is contained in:
parent
e56512125d
commit
e6039b9c70
2 changed files with 12 additions and 9 deletions
|
@ -236,18 +236,11 @@ (define (package-name)
|
|||
(string-append srcdir "/configure")
|
||||
flags))))
|
||||
|
||||
(define %parallel-job-count
|
||||
;; String to be passed next to GNU Make's `-j' argument.
|
||||
(match (getenv "NIX_BUILD_CORES")
|
||||
(#f "1")
|
||||
("0" (number->string (current-processor-count)))
|
||||
(x x)))
|
||||
|
||||
(define* (build #:key (make-flags '()) (parallel-build? #t)
|
||||
#:allow-other-keys)
|
||||
(zero? (apply system* "make"
|
||||
`(,@(if parallel-build?
|
||||
`("-j" ,%parallel-job-count)
|
||||
`("-j" ,(number->string (parallel-job-count)))
|
||||
'())
|
||||
,@make-flags))))
|
||||
|
||||
|
@ -257,7 +250,7 @@ (define* (check #:key target (make-flags '()) (tests? (not target))
|
|||
(if tests?
|
||||
(zero? (apply system* "make" test-target
|
||||
`(,@(if parallel-tests?
|
||||
`("-j" ,%parallel-job-count)
|
||||
`("-j" ,(number->string (parallel-job-count)))
|
||||
'())
|
||||
,@make-flags)))
|
||||
(begin
|
||||
|
|
|
@ -31,6 +31,8 @@ (define-module (guix build utils)
|
|||
#:re-export (alist-cons
|
||||
alist-delete)
|
||||
#:export (%store-directory
|
||||
parallel-job-count
|
||||
|
||||
directory-exists?
|
||||
executable-file?
|
||||
call-with-ascii-input-file
|
||||
|
@ -69,6 +71,14 @@ (define (%store-directory)
|
|||
(or (getenv "NIX_STORE")
|
||||
"/gnu/store"))
|
||||
|
||||
(define (parallel-job-count)
|
||||
"Return the number of processes to be passed next to GNU Make's `-j'
|
||||
argument."
|
||||
(match (getenv "NIX_BUILD_CORES") ;set by the daemon
|
||||
(#f 1)
|
||||
("0" (current-processor-count))
|
||||
(x (or (string->number x) 1))))
|
||||
|
||||
(define (directory-exists? dir)
|
||||
"Return #t if DIR exists and is a directory."
|
||||
(let ((s (stat dir #f)))
|
||||
|
|
Loading…
Reference in a new issue