[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
05/10: guix: emacs-utils: Add emacs-compile-directory.
From: |
guix-commits |
Subject: |
05/10: guix: emacs-utils: Add emacs-compile-directory. |
Date: |
Sun, 11 Sep 2022 09:48:17 -0400 (EDT) |
lilyp pushed a commit to branch master
in repository guix.
commit b54724b2ac212002fdcf8d1d722cf75ee7df24b6
Author: Liliana Marie Prikler <liliana.prikler@gmail.com>
AuthorDate: Tue Aug 9 20:26:06 2022 +0200
guix: emacs-utils: Add emacs-compile-directory.
* guix/build/emacs-utils.scm (emacs-compile-directory): New variable.
---
guix/build/emacs-utils.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 8ee547f2b3..fdca05602e 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -38,6 +38,7 @@
emacs-generate-autoloads
emacs-byte-compile-directory
+ emacs-compile-directory
emacs-header-parse
as-display
@@ -115,6 +116,35 @@ true, evaluate using dynamic scoping."
(byte-recompile-directory (file-name-as-directory ,dir) 0 1))))
(emacs-batch-eval expr)))
+(define* (emacs-compile-directory dir)
+ "Compile all files in DIR to native code.
+
+If native code is not supported, compile to bytecode instead."
+ (emacs-batch-eval
+ `(let ((byte-compile-debug t) ; for proper exit status
+ (byte+native-compile (native-comp-available-p))
+ (files (directory-files-recursively ,dir "\\.el$")))
+ (mapc
+ (lambda (file)
+ (let (byte-to-native-output-file
+ ;; First entry is the eln-cache of the homeless shelter,
+ ;; second entry is the install directory.
+ (eln-dir (and (native-comp-available-p)
+ (cadr native-comp-eln-load-path))))
+ (if byte+native-compile
+ (native-compile file
+ (comp-el-to-eln-filename file eln-dir))
+ (byte-compile-file file))
+ ;; Sadly, we can't use pcase because quasiquote works different in
+ ;; Emacs. See `batch-byte+native-compile' in comp.el for the
+ ;; actual shape of byte-to-native-output-file.
+ (unless (null byte-to-native-output-file)
+ (rename-file (car byte-to-native-output-file)
+ (cdr byte-to-native-output-file)
+ t))))
+ files))
+ #:dynamic? #t))
+
(define (emacs-header-parse section file)
"Parse the header SECTION in FILE and return it as a string."
(emacs-batch-script
- branch master updated (1da91705b0 -> d48c2c7df3), guix-commits, 2022/09/11
- 02/10: gnu: libgccjit: Build with bootstrapped gcc., guix-commits, 2022/09/11
- 04/10: gnu: emacs: Build with native compilation., guix-commits, 2022/09/11
- 01/10: gnu: Parameterize libgccjit., guix-commits, 2022/09/11
- 09/10: gnu: emacs-org: Undelete build step., guix-commits, 2022/09/11
- 05/10: guix: emacs-utils: Add emacs-compile-directory.,
guix-commits <=
- 07/10: gnu: emacs-yasnippet: Fix build., guix-commits, 2022/09/11
- 10/10: news: Add entry about Emacs native compilation., guix-commits, 2022/09/11
- 08/10: build-system: emacs: Use new function for autoloads generation, guix-commits, 2022/09/11
- 03/10: gnu: libgccjit: Build multiple versions., guix-commits, 2022/09/11
- 06/10: build-system: emacs: Use native compilation., guix-commits, 2022/09/11