Subject: [PATCH 04/26] gnu: cedille: Adjust following emacs-build-system changes.

From: Maxim Cournoyer <[email-masked]>
Date: Fri, 18 Dec 2020 17:17:01 -0500

Also enable byte compilation for most Elisp files.

* gnu/packages/cedille.scm (cedille)[arguments]: Add the cedille-mode and
se-mode to the #:include files list, which allows to...
[phases]{copy-cedille-mode}: ...remove this phase.
{extend-load-path}: New phase.
{build}: Restore phase.
{disable-byte-compilation-on-problematic-files}: New phase.
---
 gnu/packages/cedille.scm | 50 ++++++++++++++++++++++++----------------
 1 file changed, 30 insertions(+), 20 deletions(-)

diff --git a/gnu/packages/cedille.scm b/gnu/packages/cedille.scm
index d3dd576323..05eb42e9b2 100644
--- a/gnu/packages/cedille.scm
+++ b/gnu/packages/cedille.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2019 John Soo <[email-masked]>
+;;; Copyright © 2020 Maxim Cournoyer <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -49,37 +50,46 @@
        ("ghc-happy" ,ghc-happy)))
     (build-system emacs-build-system)
     (arguments
-     `(#:phases
+     `(#:include (cons* "^cedille-mode/" "^se-mode/" %default-include)
+       #:phases
        (modify-phases %standard-phases
          (add-after 'unpack 'patch-cedille-paths
            (lambda* (#:key outputs #:allow-other-keys)
              (let ((out (assoc-ref outputs "out")))
                (substitute* "cedille-mode.el"
-                 (("/usr/share/emacs/site-lisp/cedille-mode")
-                  (string-append
-                   out "/share/emacs/site-lisp/cedille")))
+                 ;; As suggested at the top of cedille-mode.el
+                 ((".*defmacro cedille-platform-case.*" all)
+                  (string-append (format #f "(defconst cedille-path ~s)~%~%"
+                                         (outputs->elpa-install-dir outputs))
+                                 all)))
                (substitute* "cedille-mode/cedille-mode-info.el"
                  (("\\(concat cedille-path-el \"cedille-info-main.info\"\\)")
                   (string-append
                    "\"" out "/share/info/cedille-info-main.info.gz\"")))
                #t)))
-         (add-after 'patch-cedille-paths 'copy-cedille-mode
+         (add-before 'build 'extend-load-path
            (lambda* (#:key outputs #:allow-other-keys)
-             (let* ((out (assoc-ref outputs "out"))
-                    (lisp
-                     (string-append
-                      out "/share/emacs/site-lisp/cedille/")))
-               (mkdir-p (string-append lisp "cedille-mode"))
-               (copy-recursively
-                "cedille-mode"
-                (string-append lisp "cedille-mode"))
-               (mkdir-p (string-append lisp "se-mode"))
-               (copy-recursively
-                "se-mode"
-                (string-append lisp "se-mode"))
-               #t)))
-         ;; FIXME: Byte compilation fails
-         (delete 'build)
+             (let ((install-dir (outputs->elpa-install-dir outputs)))
+               (setenv "EMACSLOADPATH"
+                       (string-join
+                        (cons (getenv "EMACSLOADPATH")
+                              (map (lambda (f)
+                                     (string-append install-dir "/" f))
+                                   '("cedille-mode" "se-mode")))
+                        ":")))
+             #t))
+         (add-after 'unpack 'disable-byte-compilation-on-problematic-files
+           ;; Some files fail byte compilation (see:
+           ;; https://github.com/cedille/cedille/issues/160).
+           (lambda _
+             (let ((problematic-files '("cedille-mode.el"
+                                        "cedille-mode/cedille-mode-library.el"
+                                        "se-mode/se-hole.el")))
+               (for-each (lambda (f)
+                           (make-file-writable f)
+                           (emacs-batch-disable-compilation f))
+                         problematic-files))
+             #t))
          (replace 'check
            (lambda _
              (with-directory-excursion "cedille-tests"
-- 
2.29.2