unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: 57086@debbugs.gnu.org
Subject: [bug#57086] [PATCH v3 6/7] build-system: emacs: Use native compilation.
Date: Tue, 9 Aug 2022 20:32:37 +0200	[thread overview]
Message-ID: <ca9746296eca3de7b3808383f37afbf0956b64e2.camel@gmail.com> (raw)
In-Reply-To: <4c232648145659a2c3edca6d32725d8120cc14d3.camel@gmail.com>

* 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 @@ (define* (expand-load-path #:key (prepend-source? #t) #:allow-other-keys)
         (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 @@ (define %standard-phases
   (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)
-- 
2.37.2





  parent reply	other threads:[~2022-08-25  7:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <b4c6419964da360a33377d373f034f0061619cfd.camel@gmail.com>
2022-08-09 18:37 ` bug#55657: [PATCH 0/6] Add native compilation to Emacs Liliana Marie Prikler
2022-08-05  3:29   ` [bug#57086] [PATCH v3 1/7] gnu: Parameterize libgccjit Liliana Marie Prikler
2022-08-05  3:29   ` [bug#57086] [PATCH 1/6] " Liliana Marie Prikler
2022-08-05 18:27   ` [bug#57086] [PATCH 2/6] gnu: libgccjit: Build with bootstrapped gcc Liliana Marie Prikler
2022-08-05 18:27   ` [bug#57086] [PATCH v3 2/7] " Liliana Marie Prikler
2022-08-05 18:30   ` [bug#57086] [PATCH 3/6] gnu: libgccjit: Build multiple versions Liliana Marie Prikler
2022-08-05 18:30   ` [bug#57086] [PATCH v3 3/7] " Liliana Marie Prikler
2022-08-05 22:37   ` [bug#57086] [PATCH v3 4/7] gnu: emacs: Build with native compilation Liliana Marie Prikler
2022-08-05 22:37   ` [bug#57086] [PATCH 4/6] " Liliana Marie Prikler
2022-08-09 18:26   ` [bug#57086] [PATCH 5/6] guix: emacs-utils: Add emacs-compile-directory Liliana Marie Prikler
2022-08-09 18:26     ` [bug#57086] [PATCH v2 " Liliana Marie Prikler
2022-08-09 18:26   ` [bug#57086] [PATCH v3 5/7] " Liliana Marie Prikler
2022-08-09 18:32   ` [bug#57086] [PATCH 6/6] build-system: emacs: Use native compilation Liliana Marie Prikler
2022-08-09 18:32   ` Liliana Marie Prikler [this message]
2022-08-09 21:19   ` [bug#57086] [PATCH 0/6] Add native compilation to Emacs ( via Guix-patches via
2022-08-10  4:19     ` Liliana Marie Prikler
2022-08-10  6:11       ` ( via Guix-patches via
2022-08-23 20:07     ` Liliana Marie Prikler
2022-08-24 21:59   ` [bug#57086] [PATCH v3 7/7] gnu: emacs-yasnippet: Fix build Liliana Marie Prikler
2022-08-25  7:08   ` [bug#57086] [PATCH v3 0/7] Add native compilation to Emacs Liliana Marie Prikler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ca9746296eca3de7b3808383f37afbf0956b64e2.camel@gmail.com \
    --to=liliana.prikler@gmail.com \
    --cc=57086@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).