[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug#57086] [PATCH 5/6] guix: emacs-utils: Add emacs-compile-directory.
From: |
Liliana Marie Prikler |
Subject: |
[bug#57086] [PATCH 5/6] guix: emacs-utils: Add emacs-compile-directory. |
Date: |
Tue, 9 Aug 2022 20:26:06 +0200 |
* guix/build/emacs-utils.scm (emacs-compile-directory): New variable.
---
guix/build/emacs-utils.scm | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/guix/build/emacs-utils.scm b/guix/build/emacs-utils.scm
index 8ee547f2b3..17155a0b8b 100644
--- a/guix/build/emacs-utils.scm
+++ b/guix/build/emacs-utils.scm
@@ -38,6 +38,7 @@ (define-module (guix build emacs-utils)
emacs-generate-autoloads
emacs-byte-compile-directory
+ emacs-compile-directory
emacs-header-parse
as-display
@@ -115,6 +116,31 @@ (define* (emacs-byte-compile-directory dir)
(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)
+ (if byte+native-compile
+ (native-compile file (concat (file-name-sans-extension file)
+ ".eln"))
+ (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
--
2.37.0
- [bug#57086] [PATCH 0/6] Add native compilation to Emacs, Liliana Marie Prikler, 2022/08/09
- [bug#57086] [PATCH 4/6] gnu: emacs: Build with native compilation., Liliana Marie Prikler, 2022/08/09
- [bug#57086] [PATCH 6/6] build-system: emacs: Use native compilation., Liliana Marie Prikler, 2022/08/09
- [bug#57086] [PATCH 5/6] guix: emacs-utils: Add emacs-compile-directory.,
Liliana Marie Prikler <=
- [bug#57086] [PATCH 3/6] gnu: libgccjit: Build multiple versions., Liliana Marie Prikler, 2022/08/09
- [bug#57086] [PATCH 1/6] gnu: Parameterize libgccjit., Liliana Marie Prikler, 2022/08/09
- [bug#57086] [PATCH 2/6] gnu: libgccjit: Build with bootstrapped gcc., Liliana Marie Prikler, 2022/08/09
- [bug#57086] [PATCH 0/6] Add native compilation to Emacs, (, 2022/08/09
- [bug#57086] [PATCH v3 0/7] Add native compilation to Emacs, Liliana Marie Prikler, 2022/08/25
- [bug#57086] [PATCH v3 2/7] gnu: libgccjit: Build with bootstrapped gcc., Liliana Marie Prikler, 2022/08/25