From f6526eb330c6be9c20cf9486b59d7f9ea84ffda3 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 25 Nov 2014 22:32:26 +0100 Subject: guix build: Add '--max-jobs' option. Suggested by Deck Pickard . * 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'. --- guix/scripts/build.scm | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'guix/scripts/build.scm') diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 7b7f419f3a..b4aa33b3a0 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -119,7 +119,9 @@ (define (show-build-options-help) (display (_ " --verbosity=LEVEL use the given verbosity LEVEL")) (display (_ " - -c, --cores=N allow the use of up to N CPU cores for the build"))) + -c, --cores=N allow the use of up to N CPU cores for the build")) + (display (_ " + -M, --max-jobs=N allow at most N build jobs"))) (define (set-build-options-from-command-line store opts) "Given OPTS, an alist as returned by 'args-fold' given @@ -128,6 +130,7 @@ (define (set-build-options-from-command-line store opts) (set-build-options store #:keep-failed? (assoc-ref opts 'keep-failed?) #:build-cores (or (assoc-ref opts 'cores) 0) + #:max-build-jobs (or (assoc-ref opts 'max-jobs) 1) #:fallback? (assoc-ref opts 'fallback?) #:use-substitutes? (assoc-ref opts 'substitutes?) #:use-build-hook? (assoc-ref opts 'build-hook?) @@ -192,7 +195,15 @@ (define %standard-build-options (let ((c (false-if-exception (string->number arg)))) (if c (apply values (alist-cons 'cores c result) rest) - (leave (_ "~a: not a number~%") arg))))))) + (leave (_ "not a number: '~a' option argument: ~a~%") + name arg))))) + (option '(#\M "max-jobs") #t #f + (lambda (opt name arg result . rest) + (let ((c (false-if-exception (string->number arg)))) + (if c + (apply values (alist-cons 'max-jobs c result) rest) + (leave (_ "not a number: '~a' option argument: ~a~%") + name arg))))))) ;;; -- cgit v1.2.3