<
aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
;;; Copyright © 2016, 2017, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(use-modules (ice-9 format)
             (ice-9 match)
             (ice-9 threads)
             (srfi srfi-1)
             (guix build compile)
             (guix build utils))

(define host (getenv "host"))
(define srcdir (getenv "srcdir"))

(define (relative-file file)
  (if (string-prefix? (string-append srcdir "/") file)
      (string-drop file (+ 1 (string-length srcdir)))
      file))

(define (file-mtime<? f1 f2)
  (< (stat:mtime (stat f1))
     (stat:mtime (stat f2))))

(define (scm->go file)
  (let* ((relative (relative-file file))
         (without-extension (string-drop-right relative 4)))
    (string-append without-extension ".go")))

(define (file-needs-compilation? file)
  (let ((go (scm->go file)))
    (or (not (file-exists? go))
        (file-mtime<? go file))))

(define* (parallel-job-count #:optional (flags (getenv "MAKEFLAGS")))
  "Return the number of parallel jobs as determined by FLAGS, the flags passed
to 'make'."
  (match flags
    (#f (current-processor-count))
    (flags
     (let ((initial-flags (string-tokenize flags)))
       (let loop ((flags initial-flags))
         (match flags
           (()
            ;; Note: GNU make prior to version 4.2 would hide "-j" flags from
            ;; $MAKEFLAGS.  Thus, check for a "--jobserver" flag here and
            ;; assume we're using all cores if specified.
            (if (any (lambda (flag)
                       (string-prefix? "--jobserver" flag))
                     initial-flags)
                (current-processor-count)         ;GNU make < 4.2
                1))                               ;sequential make
           (("-j" (= string->number count) _ ...)
            (if (integer? count)
                count
                (current-processor-count)))
           ((head tail ...)
            (if (string-prefix? "-j" head)
                (match (string-drop head 2)
                  (""
                   (current-processor-count))
                  ((= string->number count)
                   (if (integer? count)
                       count
                       (current-processor-count))))
                (loop tail)))))))))

(define (parallel-job-count*)
  ;; XXX: Work around memory requirements not sustainable on i686 above '-j4'
  ;; or so: <https://bugs.gnu.org/40522>.
  (let ((count (parallel-job-count)))
    (if (string-prefix? "i686" %host-type)
        (min count 4)
        count)))

(define (% completed total)
  "Return the completion percentage of COMPLETED over TOTAL as an integer."
  (inexact->exact (round (* 100. (/ completed total)))))

;; Install a SIGINT handler to give unwind handlers in 'compile-file' an
;; opportunity to run upon SIGINT and to remove temporary output files.
(sigaction SIGINT
  (lambda args
    (exit 1)))

(match (command-line)
  ((_ "--total" (= string->number grand-total)
      "--completed" (= string->number processed)
      . files)
   ;; GRAND-TOTAL is the total number of .scm files in the project; PROCESSED
   ;; is the total number of .scm files already compiled in previous
   ;; invocations of this script.
   (catch #t
     (lambda ()
       (let* ((to-build  (filter file-needs-compilation? files))
              (processed (+ processed
                            (- (length files) (length to-build)))))
         (compile-files srcdir (getcwd) to-build
                        #:workers (parallel-job-count*)
                        #:host host
                        #:report-load (lambda (file total completed)
                                        (when file
                                          (format #t "[~3d%] LOAD     ~a~%"
                                                  (% (+ 1 completed
                                                          (* 2 processed))
                                                     (* 2 grand-total))
                                                  file)
                                          (force-output)))
                        #:report-compilation (lambda (file total completed)
                                               (when file
                                                 (format #t "[~3d%] GUILEC   ~a~%"
                                                         (% (+ total completed 1
                                                                     (* 2 processed))
                                                            (* 2 grand-total))
                                                         (scm->go file))
                                                 (force-output))))))
     (lambda _
       (primitive-exit 1))
     (lambda args
       ;; Try to report the error in an intelligible way.
       (let* ((stack   (make-stack #t))
              (frame   (if (> (stack-length stack) 1)
                           (stack-ref stack 1)    ;skip the 'throw' frame
                           (stack-ref stack 0)))
              (ui      (false-if-exception
                        (resolve-module '(guix ui))))
              (report  (and ui
                            (false-if-exception
                             (module-ref ui 'report-load-error)))))
         (if report
             (report (or (and=> (current-load-port) port-filename) "?.scm")
                     args frame)
             (begin
               (print-exception (current-error-port) frame
                                (car args) (cdr args))
               (display-backtrace stack (current-error-port)))))))))
....Restores compatibility with Python 3.10. * gnu/packages/python-xyz.scm (python-pyopengl-accelerate): Update to 3.1.6. Lars-Dominik Braun 2023-05-11gnu: python-pyopengl: Update to 3.1.6....* gnu/packages/python-xyz.scm (python-pyopengl): Update to 3.1.6. Lars-Dominik Braun 2023-05-11gnu: automake: Fix cross-build....This is a follow-up to commit ea908c1c04804e51dbd156981c21d8397367d40d gnu: automake: Remove input labels. * gnu/packages/autotools.scm (automake)[arguments]: Use "#~" instead of "'". Janneke Nieuwenhuizen 2023-05-11gnu: autoconf: Fix cross-build....This is a follow-up to commit 8fa17cb6d51901b2c8a0e20954c5b19f8057c217 gnu: autoconf: Remove input labels. * gnu/packages/autotools.scm (autoconf-2.69)[arguments]: Use "#~" instead of "'". Janneke Nieuwenhuizen 2023-05-10gnu: kodi: Fix build against latest mesa....* gnu/packages/patches/kodi-mesa-eglchromium.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/kodi.scm (kodi)[source]: Use it. Eric Bavier 2023-05-10gnu: kodi: Fix build with latest glibc....* gnu/packages/kodi.scm (kodi)[inputs]: Use most recent 'fmt' and 'spdlog' packages. * gnu/packages/logging.scm (spdlog-for-kodi): Delete. Eric Bavier 2023-05-10gnu: Add python-pytorch-lightning....* gnu/packages/machine-learning.scm (python-pytorch-lightning): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-jsonargparse....* gnu/packages/python-xyz.scm (python-jsonargparse): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-docstring-parser....* gnu/packages/python-xyz.scm (python-docstring-parser): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-starsessions-for-pytorch-lightning....* gnu/packages/python-web.scm (python-starsessions-for-pytorch-lightning): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-typeshed-client....* gnu/packages/python-xyz.scm (python-typeshed-client): New variable. Ricardo Wurmus 2023-05-10gnu: python-torchvision: Update to 0.15.2....* gnu/packages/machine-learning.scm (python-torchvision): Update to 0.15.2. [build-system]: Use pyproject-build-system. [arguments]: Remove custom 'check phase. Ricardo Wurmus 2023-05-10gnu: python-arrow: Update to 1.2.3....* gnu/packages/time.scm (python-arrow): Update to 1.2.3. Ricardo Wurmus 2023-05-10gnu: Add python-types-requests....* gnu/packages/python-xyz.scm (python-types-requests): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-types-urllib3....* gnu/packages/python-xyz.scm (python-types-urllib3): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-fastapi-for-pytorch-lightning....* gnu/packages/python-web.scm (python-fastapi-for-pytorch-lightning): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-starlette-for-fastapi-0.88....* gnu/packages/python-web.scm (python-starlette-for-fastapi-0.88): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-inquirer....* gnu/packages/machine-learning.scm (python-inquirer): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-readchar....* gnu/packages/machine-learning.scm (python-readchar): New variable. Ricardo Wurmus 2023-05-10gnu: python-scikit-optimize: Fix build with newer numpy and sklearn....* gnu/packages/patches/python-scikit-optimize-1148.patch, gnu/packages/patches/python-scikit-optimize-1150.patch: New patches. * gnu/local.mk (dist_patch_DATA): Add them. * gnu/packages/python-science.scm (python-scikit-optimize)[source]: Fetch with git and apply patches. Ricardo Wurmus 2023-05-10gnu: Add python-dateutils....* gnu/packages/time.scm (python-dateutils): New variable. Ricardo Wurmus 2023-05-10gnu: python-pillow-simd: Update to 9.2.0....* gnu/packages/python-xyz.scm (python-pillow-simd): Update to 9.2.0. Ricardo Wurmus 2023-05-10gnu: python-blessed: Update to 1.20.0....* gnu/packages/python-xyz.scm (python-blessed): Update to 1.20.0. [source]: Simplify snippet. [build-system]: Use pyproject-build-system. [arguments]: Use test-flags to avoid pytest-coverage; remove custom 'check phase. [propagated-inputs]: Remove python-jinxed python-six. [native-inputs]: Remove python-mock. Ricardo Wurmus 2023-05-10gnu: Add python-torchmetrics....* gnu/packages/machine-learning.scm (python-torchmetrics): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-types-setuptools....* gnu/packages/python-xyz.scm (python-types-setuptools): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-mir-eval....* gnu/packages/python-xyz.scm (python-mir-eval): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-lightning-utilities....* gnu/packages/machine-learning.scm (python-lightning-utilities): New variable. Ricardo Wurmus 2023-05-10gnu: Add python-lightning-cloud....* gnu/packages/machine-learning.scm (python-lightning-cloud): New variable. Ricardo Wurmus 2023-05-10gnu: python-pytorch-for-r-torch: Define as alias for python-pytorch....* gnu/packages/machine-learning.scm (python-pytorch-for-r-torch): Remove duplicate definition. Ricardo Wurmus 2023-05-10gnu: python-traitlets: Update to 5.9.0....* gnu/packages/python-xyz.scm (python-traitlets): Update to 5.9.0. [build-system]: Use pyproject-build-system. [native-inputs]: Add python-hatchling, python-pre-commit, and python-pytest-mock. [arguments]: Remove custom 'check phase. Ricardo Wurmus 2023-05-10gnu: Add python-deepdiff....* gnu/packages/python-xyz.scm (python-deepdiff): New variable. Ricardo Wurmus 2023-05-10gnu: python-pytorch: Update to 1.13.1....* gnu/packages/machine-learning.scm (python-pytorch): Update to 1.13.1. [source]: Update snippet. Ricardo Wurmus 2023-05-10gnu: python-shiboken-2: Add fix for python-pyside-2....* gnu/packages/qt.scm (python-shiboken-2)[arguments]: Add 'workaround-importlib-error' phase. Guillaume Le Vaillant 2023-05-10gnu: guile-fibers-next: Update to 1.2.0-2.745bd40....* gnu/packages/guile-xyz.scm (guile-fibers-next): Update to 1.2.0-2.745bd40. Signed-off-by: Christopher Baines <mail@cbaines.net> Christopher Baines 2023-05-10services: guix-build-coordinator-agent: Support max-parallel-uploads....This should be usable with the new guile-gnutls. * gnu/services/guix.scm (guix-build-coordinator-agent-configuration-max-parallel-uploads): New procedure. * gnu/services/guix.scm (guix-build-coordinator-agent-shepherd-services): Use the new argument. * doc/guix.texi (Guix Services): Document it. Christopher Baines 2023-05-10gnu: guix-build-coordinator: Update to 0-81.3f6473c....* gnu/packages/package-management.scm (guix-build-coordinator): Update to 0-81.3f6473c. Christopher Baines 2023-05-10gnu: guile-gnutls: Update to 3.7.12....* gnu/packages/tls.scm (guile-gnutls): Update to 3.7.12. [source]: Switch to a tarball, to avoid a circular dependency if guile-gnutls is used in git-download. [arguments]: Remove phase changes for building from Git. [native-inputs]: Remove autoconf and automake as they're now unnecessary. Signed-off-by: Christopher Baines <mail@cbaines.net> Christopher Baines 2023-05-10doc: Fix module name for 'home-znc-service-type'....* doc/guix.texi (Messaging Home Services): Fix. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Blake Shaw 2023-05-10gnu: cuirass: Update to 4a8a4bc....Fixes <https://issues.guix.gnu.org/63389>. * gnu/packages/ci.scm (cuirass): Update to 4a8a4bc. [arguments]: Remove 'set-PATH-for-tests' and 'disable-remote-tests' phases, which are unnecessary. In 'wrap-program' phase, check for "guile-gnutls". [inputs]: Replace GUILE-FIBERS with GUILE-FIBERS-1.1 and GNUTLS with GUILE-GNUTLS. Ludovic Courtès