emacs-build-system: Byte compile the autoload files.

* guix/build/emacs-build-system.scm (enable-autoloads-compilation)
(validate-compiled-autoloads): Add procedures.
(%standard-phases): Register the new procedures.
* gnu/packages/aux-files/emacs/guix-emacs.el (guix-emacs-find-autoloads):
Remove duplicates in the list of autoload files found.
* guix/build/emacs-utils.scm (expr->string): Add procedure.
(emacs-batch-eval, emacs-batch-edit-file): Use it.
This commit is contained in:
Maxim Cournoyer 2019-12-06 15:12:32 +09:00
parent 4714d0fc1a
commit 9659459f06
No known key found for this signature in database
GPG Key ID: 1260E46482E63562
3 changed files with 31 additions and 6 deletions

View File

@ -35,8 +35,9 @@
"Return a list of Emacs 'autoloads' files in DIRECTORY.
The files in the list do not have extensions (.el, .elc)."
;; `directory-files' doesn't honor group in regexp.
(mapcar #'file-name-sans-extension
(directory-files directory 'full-name guix-emacs-autoloads-regexp)))
(delete-dups (mapcar #'file-name-sans-extension
(directory-files directory 'full-name
guix-emacs-autoloads-regexp))))
;;;###autoload
(defun guix-emacs-autoload-packages ()

View File

@ -225,6 +225,21 @@ parallel. PARALLEL-TESTS? is ignored when using a non-make TEST-COMMAND."
(parameterize ((%emacs emacs))
(emacs-generate-autoloads elpa-name site-lisp))))
(define* (enable-autoloads-compilation #:key outputs #:allow-other-keys)
"Remove the NO-BYTE-COMPILATION local variable embedded in the generated
autoload files."
(let* ((out (assoc-ref outputs "out"))
(autoloads (find-files out "-autoloads.el$")))
(substitute* autoloads
((";; no-byte-compile.*") ""))
#t))
(define* (validate-compiled-autoloads #:key outputs #:allow-other-keys)
"Verify whether the byte compiled autoloads load fine."
(let* ((out (assoc-ref outputs "out"))
(autoloads (find-files out "-autoloads.elc$")))
(emacs-batch-eval (format #f "(mapc #'load '~s)" autoloads))))
(define (emacs-package? name)
"Check if NAME correspond to the name of an Emacs package."
(string-prefix? "emacs-" name))
@ -253,10 +268,13 @@ second hyphen. This corresponds to 'name-version' as used in ELPA packages."
(replace 'check check)
(replace 'install install)
(add-after 'install 'make-autoloads make-autoloads)
(add-after 'make-autoloads 'patch-el-files patch-el-files)
(add-after 'make-autoloads 'enable-autoloads-compilation
enable-autoloads-compilation)
(add-after 'enable-autoloads-compilation 'patch-el-files patch-el-files)
;; The .el files are byte compiled directly in the store.
(add-after 'patch-el-files 'build build)
(add-after 'build 'move-doc move-doc)))
(add-after 'build 'validate-compiled-autoloads validate-compiled-autoloads)
(add-after 'validate-compiled-autoloads 'move-doc move-doc)))
(define* (emacs-build #:key inputs (phases %standard-phases)
#:allow-other-keys #:rest args)

View File

@ -41,16 +41,22 @@
;; The `emacs' command.
(make-parameter "emacs"))
(define (expr->string expr)
"Converts EXPR, an expression, into a string."
(if (string? expr)
expr
(format #f "~s" expr)))
(define (emacs-batch-eval expr)
"Run Emacs in batch mode, and execute the elisp code EXPR."
(invoke (%emacs) "--quick" "--batch"
(format #f "--eval=~S" expr)))
(string-append "--eval=" (expr->string expr))))
(define (emacs-batch-edit-file file expr)
"Load FILE in Emacs using batch mode, and execute the elisp code EXPR."
(invoke (%emacs) "--quick" "--batch"
(string-append "--visit=" file)
(format #f "--eval=~S" expr)))
(string-append "--eval=" (expr->string expr))))
(define (emacs-batch-disable-compilation file)
(emacs-batch-edit-file file