Support build-cores = 0; change `guix-build' to default to 0.
* guix/build/gnu-build-system.scm (%parallel-job-count): New variable. (build, check): Use it instead of $NIX_BUILD_CORES. * guix-build.in (guix-build): Default to 0 for the #:build-cores option.
This commit is contained in:
		
							parent
							
								
									7da7ae937e
								
							
						
					
					
						commit
						db1a15314d
					
				
					 2 changed files with 10 additions and 4 deletions
				
			
		| 
						 | 
					@ -198,8 +198,7 @@ Report bugs to: ~a.~%") "@PACKAGE_BUGREPORT@"))
 | 
				
			||||||
    ;; TODO: Add more options.
 | 
					    ;; TODO: Add more options.
 | 
				
			||||||
    (set-build-options %store
 | 
					    (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)
 | 
					                       #:build-cores (or (assoc-ref opts 'cores) 0))
 | 
				
			||||||
                                         (current-processor-count)))
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    (if (assoc-ref opts 'derivations-only?)
 | 
					    (if (assoc-ref opts 'derivations-only?)
 | 
				
			||||||
        (format #t "~{~a~%~}" drv)
 | 
					        (format #t "~{~a~%~}" drv)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -128,11 +128,18 @@
 | 
				
			||||||
                  (string-append srcdir "/configure")
 | 
					                  (string-append srcdir "/configure")
 | 
				
			||||||
                  flags))))
 | 
					                  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)
 | 
					(define* (build #:key (make-flags '()) (parallel-build? #t)
 | 
				
			||||||
                #:allow-other-keys)
 | 
					                #:allow-other-keys)
 | 
				
			||||||
  (zero? (apply system* "make"
 | 
					  (zero? (apply system* "make"
 | 
				
			||||||
                `(,@(if parallel-build?
 | 
					                `(,@(if parallel-build?
 | 
				
			||||||
                        `("-j" ,(getenv "NIX_BUILD_CORES"))
 | 
					                        `("-j" ,%parallel-job-count)
 | 
				
			||||||
                        '())
 | 
					                        '())
 | 
				
			||||||
                  ,@make-flags))))
 | 
					                  ,@make-flags))))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -142,7 +149,7 @@
 | 
				
			||||||
  (if tests?
 | 
					  (if tests?
 | 
				
			||||||
      (zero? (apply system* "make" test-target
 | 
					      (zero? (apply system* "make" test-target
 | 
				
			||||||
                    `(,@(if parallel-tests?
 | 
					                    `(,@(if parallel-tests?
 | 
				
			||||||
                            `("-j" ,(getenv "NIX_BUILD_CORES"))
 | 
					                            `("-j" ,%parallel-job-count)
 | 
				
			||||||
                            '())
 | 
					                            '())
 | 
				
			||||||
                      ,@make-flags)))
 | 
					                      ,@make-flags)))
 | 
				
			||||||
      (begin
 | 
					      (begin
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Reference in a new issue