diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2014-11-25 22:32:26 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2014-11-25 22:37:44 +0100 |
| commit | f6526eb330c6be9c20cf9486b59d7f9ea84ffda3 (patch) | |
| tree | 3427d23e92b0cdb583b82b4f0fde26241b32e1d6 | |
| parent | 1b366ee4f6dff35b3bef259f4a64832b580178c9 (diff) | |
guix build: Add '--max-jobs' option.
Suggested by Deck Pickard <deck.r.pickard@gmail.com>.
* guix/scripts/build.scm (show-build-options-help): Document
--max-jobs.
(set-build-options-from-command-line): Pass #:max-build-jobs.
(%standard-build-options): Add --max-jobs.
* doc/guix.texi (Invoking guix-daemon): Document the meaning of
'--max-jobs 0'.
(Invoking guix build): Document --max-jobs, with a reference to
"Invoking guix-daemon'.
| -rw-r--r-- | doc/guix.texi | 10 | ||||
| -rw-r--r-- | guix/scripts/build.scm | 15 |
2 files changed, 22 insertions, 3 deletions
diff --git a/doc/guix.texi b/doc/guix.texi index a88b7747fcb..fe1f8a8b765 100644 --- a/doc/guix.texi +++ b/doc/guix.texi | |||
| @@ -596,7 +596,9 @@ parallelism---for instance, by running @code{make -j$NIX_BUILD_CORES}. | |||
| 596 | @item --max-jobs=@var{n} | 596 | @item --max-jobs=@var{n} |
| 597 | @itemx -M @var{n} | 597 | @itemx -M @var{n} |
| 598 | Allow at most @var{n} build jobs in parallel. The default value is | 598 | Allow at most @var{n} build jobs in parallel. The default value is |
| 599 | @code{1}. | 599 | @code{1}. Setting it to @code{0} means that no builds will be performed |
| 600 | locally; instead, the daemon will offload builds (@pxref{Daemon Offload | ||
| 601 | Setup}), or simply fail. | ||
| 600 | 602 | ||
| 601 | @item --debug | 603 | @item --debug |
| 602 | Produce debugging output. | 604 | Produce debugging output. |
| @@ -2765,6 +2767,12 @@ may be helpful when debugging setup issues with the build daemon. | |||
| 2765 | Allow the use of up to @var{n} CPU cores for the build. The special | 2767 | Allow the use of up to @var{n} CPU cores for the build. The special |
| 2766 | value @code{0} means to use as many CPU cores as available. | 2768 | value @code{0} means to use as many CPU cores as available. |
| 2767 | 2769 | ||
| 2770 | @item --max-jobs=@var{n} | ||
| 2771 | @itemx -M @var{n} | ||
| 2772 | Allow at most @var{n} build jobs in parallel. @xref{Invoking | ||
| 2773 | guix-daemon, @code{--max-jobs}}, for details about this option and the | ||
| 2774 | equivalent @command{guix-daemon} option. | ||
| 2775 | |||
| 2768 | @end table | 2776 | @end table |
| 2769 | 2777 | ||
| 2770 | Behind the scenes, @command{guix build} is essentially an interface to | 2778 | Behind the scenes, @command{guix build} is essentially an interface to |
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 7b7f419f3af..b4aa33b3a00 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm | |||
| @@ -119,7 +119,9 @@ options handled by 'set-build-options-from-command-line', and listed in | |||
| 119 | (display (_ " | 119 | (display (_ " |
| 120 | --verbosity=LEVEL use the given verbosity LEVEL")) | 120 | --verbosity=LEVEL use the given verbosity LEVEL")) |
| 121 | (display (_ " | 121 | (display (_ " |
| 122 | -c, --cores=N allow the use of up to N CPU cores for the build"))) | 122 | -c, --cores=N allow the use of up to N CPU cores for the build")) |
| 123 | (display (_ " | ||
| 124 | -M, --max-jobs=N allow at most N build jobs"))) | ||
| 123 | 125 | ||
| 124 | (define (set-build-options-from-command-line store opts) | 126 | (define (set-build-options-from-command-line store opts) |
| 125 | "Given OPTS, an alist as returned by 'args-fold' given | 127 | "Given OPTS, an alist as returned by 'args-fold' given |
| @@ -128,6 +130,7 @@ options handled by 'set-build-options-from-command-line', and listed in | |||
| 128 | (set-build-options store | 130 | (set-build-options store |
| 129 | #:keep-failed? (assoc-ref opts 'keep-failed?) | 131 | #:keep-failed? (assoc-ref opts 'keep-failed?) |
| 130 | #:build-cores (or (assoc-ref opts 'cores) 0) | 132 | #:build-cores (or (assoc-ref opts 'cores) 0) |
| 133 | #:max-build-jobs (or (assoc-ref opts 'max-jobs) 1) | ||
| 131 | #:fallback? (assoc-ref opts 'fallback?) | 134 | #:fallback? (assoc-ref opts 'fallback?) |
| 132 | #:use-substitutes? (assoc-ref opts 'substitutes?) | 135 | #:use-substitutes? (assoc-ref opts 'substitutes?) |
| 133 | #:use-build-hook? (assoc-ref opts 'build-hook?) | 136 | #:use-build-hook? (assoc-ref opts 'build-hook?) |
| @@ -192,7 +195,15 @@ options handled by 'set-build-options-from-command-line', and listed in | |||
| 192 | (let ((c (false-if-exception (string->number arg)))) | 195 | (let ((c (false-if-exception (string->number arg)))) |
| 193 | (if c | 196 | (if c |
| 194 | (apply values (alist-cons 'cores c result) rest) | 197 | (apply values (alist-cons 'cores c result) rest) |
| 195 | (leave (_ "~a: not a number~%") arg))))))) | 198 | (leave (_ "not a number: '~a' option argument: ~a~%") |
| 199 | name arg))))) | ||
| 200 | (option '(#\M "max-jobs") #t #f | ||
| 201 | (lambda (opt name arg result . rest) | ||
| 202 | (let ((c (false-if-exception (string->number arg)))) | ||
| 203 | (if c | ||
| 204 | (apply values (alist-cons 'max-jobs c result) rest) | ||
| 205 | (leave (_ "not a number: '~a' option argument: ~a~%") | ||
| 206 | name arg))))))) | ||
| 196 | 207 | ||
| 197 | 208 | ||
| 198 | ;;; | 209 | ;;; |
