guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

06/10: build-system: emacs: Use native compilation.


From: guix-commits
Subject: 06/10: build-system: emacs: Use native compilation.
Date: Sun, 11 Sep 2022 09:48:18 -0400 (EDT)

lilyp pushed a commit to branch master
in repository guix.

commit 630c9b6e01833f228b83e24d517f4f9e940616f6
Author: Liliana Marie Prikler <liliana.prikler@gmail.com>
AuthorDate: Tue Aug 9 20:32:37 2022 +0200

    build-system: emacs: Use native compilation.
    
    * guix/build/emacs-build-system.scm (add-install-to-native-load-path):
    New variable.
    (build): Replace ‘emacs-byte-compile-directory’ with 
‘emacs-compile-directory’.
    Delete already compiled files in the working directory prior to compilation.
    (%standard-phases): Add ‘add-install-to-native-load-path’ after
    ‘expand-load-path’.
---
 guix/build/emacs-build-system.scm | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/guix/build/emacs-build-system.scm 
b/guix/build/emacs-build-system.scm
index 6a6918bfdd..3808b60445 100644
--- a/guix/build/emacs-build-system.scm
+++ b/guix/build/emacs-build-system.scm
@@ -108,13 +108,29 @@ environment variable\n" source-directory))
         (format #t "expanded load paths for ~{~a~^, ~}\n"
                 (map basename diff))))))
 
+(define* (add-install-to-native-load-path #:key outputs #:allow-other-keys)
+  "Append the native-site-lisp of OUTPUT to EMACSNATIVELOADPATH."
+  (let ((native-load-path (or (false-if-exception
+                               (string-split (getenv "EMACSNATIVELOADPATH") 
#\:))
+                              '()))
+        (install-directory (string-append (assoc-ref outputs "out")
+                                          "/lib/emacs/native-site-lisp")))
+    (setenv "EMACSNATIVELOADPATH"
+            ;; Emacs pushes these directories in reverse order, so the
+            ;; last one will be the first.
+            (string-join `(,@native-load-path ,install-directory)
+                         ":"))))
+
 (define* (build #:key outputs inputs #:allow-other-keys)
   "Compile .el files."
+  ;; Ensure that already compiled files in the working directory don't shadow
+  ;; the build.  Might happen, because check runs first.
+  (for-each delete-file (find-files "." "\\.el[cn]$"))
   (let* ((emacs (search-input-file inputs "/bin/emacs"))
          (out (assoc-ref outputs "out")))
     (setenv "SHELL" "sh")
     (parameterize ((%emacs emacs))
-      (emacs-byte-compile-directory (elpa-directory out)))))
+      (emacs-compile-directory (elpa-directory out)))))
 
 (define* (patch-el-files #:key outputs #:allow-other-keys)
   "Substitute the absolute \"/bin/\" directory with the right location in the
@@ -343,6 +359,8 @@ for libraries following the ELPA convention."
   (modify-phases gnu:%standard-phases
     (replace 'unpack unpack)
     (add-after 'unpack 'expand-load-path expand-load-path)
+    (add-after 'expand-load-path 'add-install-to-native-load-path
+      add-install-to-native-load-path)
     (delete 'bootstrap)
     (delete 'configure)
     (delete 'build)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]