me
/
guix
Archived
1
0
Fork 0

guix-build: Add `--cores'.

* guix-build.in (leave): New macro, formerly in `guix-build'.
  (show-help): Document `--cores'.
  (%options): Add `--cores'.
  (guix-build): Remove `leave' macro from here.  Pass the `cores' option
  value to `set-build-options'.
master
Ludovic Courtès 2012-07-07 16:50:40 +02:00
parent febaa88569
commit fa14d96e6f
1 changed files with 77 additions and 67 deletions

View File

@ -64,6 +64,12 @@ exec ${GUILE-@GUILE@} -L "@guilemoduledir@" -l "$0" \
;; Alist of default option values.
'())
(define-syntax-rule (leave fmt args ...)
"Format FMT and ARGS to the error port and exit."
(begin
(format (current-error-port) fmt args ...)
(exit 1)))
(define (show-version)
(display "guix-build (@PACKAGE_NAME@) @PACKAGE_VERSION@\n"))
@ -76,6 +82,8 @@ Build the given PACKAGE-OR-DERIVATION and return their output paths.\n"))
-K, --keep-failed keep build tree of failed builds"))
(display (_ "
-n, --dry-run do not build the derivations"))
(display (_ "
-c, --cores=N allow the use of up to N CPU cores for the build"))
(newline)
(display (_ "
-h, --help display this help and exit"))
@ -104,6 +112,12 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
(option '(#\K "keep-failed") #f #f
(lambda (opt name arg result)
(alist-cons 'keep-failed? #t result)))
(option '(#\c "cores") #t #f
(lambda (opt name arg result)
(let ((c (false-if-exception (string->number arg))))
(if c
(alist-cons 'cores c result)
(leave (_ "~a: not a number~%") arg)))))
(option '(#\n "dry-run") #f #F
(lambda (opt name arg result)
(alist-cons 'dry-run? #t result)))))
@ -114,16 +128,11 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
;;;
(define (guix-build . args)
(let-syntax ((leave (syntax-rules ()
((_ fmt args ...)
(begin
(format (current-error-port) fmt args ...)
(exit 1))))))
(define (parse-options)
;; Return the alist of option values.
(args-fold args %options
(lambda (opt name arg result)
(leave (_ "~A: unrecognized option") opt))
(leave (_ "~A: unrecognized option~%") opt))
(lambda (arg result)
(alist-cons 'argument arg result))
%default-options))
@ -144,7 +153,7 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
((p _ ...)
(package-derivation %store p))
(_
(leave (_ "~A: unknown package") x))))
(leave (_ "~A: unknown package~%") x))))
(_ #f))
opts))
(req (append-map (lambda (drv-path)
@ -171,7 +180,8 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
;; TODO: Add more options.
(set-build-options %store
#:keep-failed? (assoc-ref opts 'keep-failed?))
#:keep-failed? (assoc-ref opts 'keep-failed?)
#:build-cores (or (assoc-ref opts 'cores) 1))
(or (assoc-ref opts 'dry-run?)
(and (build-derivations %store drv)
@ -184,4 +194,4 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
(derivation-path->output-path
d out-name)))
(derivation-outputs drv)))))
drv))))))
drv)))))