Skip to content

Commit

Permalink
Fix handling of files with no-byte-compile set to t; was accidental…
Browse files Browse the repository at this point in the history
…ly broken way back in commit 1b5061f and never noticed (issue #103).
  • Loading branch information
doublep committed Mar 17, 2024
1 parent 49322c7 commit 341ac1f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
8 changes: 6 additions & 2 deletions eldev-build.el
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,14 @@ possible to build arbitrary targets this way."
(with-temp-buffer
(insert-file-contents source)
;; Older versions don't understand `no-mode'.
(hack-local-variables (when (>= emacs-major-version 26) 'no-mode))))))
(hack-local-variables (when (>= emacs-major-version 26) 'no-mode))
no-byte-compile))))
;; Don't do anything with `no-byte-compile' files (not even load) unless called
;; recursively. Otherwise we might e.g. attempt loading `define-package' and fail.
(unless skip-byte-compilation
(if skip-byte-compilation
;; FIXME: Think of a way of not even trying to build such files. Otherwise the
;; output ("ELC blabla.el") is confusing.
(eldev-verbose "Cancelled byte-compilation of `%s': it has `no-byte-compile' local variable" source)
(eldev-verbose (if recursive "Byte-compiling file `%s' early as `require'd from another file..." "Byte-compiling file `%s'...")
source)
(eldev-advised ('load :before
Expand Down
9 changes: 9 additions & 0 deletions test/compile.el
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@
(eldev--test-assert-files project-dir preexisting-files "src/project-l.elc" "src/project-l-misc.elc" "src/project-l-util.elc")
(should (= exit-code 0)))))

(eldev-ert-defargtest eldev-compile-everything-8 (on-demand)
(nil 'normal 'noisy)
;; `project-j' has a file with `no-byte-compile' and autoloads.
(eldev--test-without-files "project-j" ("project-j-autoloads.el" "project-j.elc" "project-j-advanced.elc")
(should (member "project-j-uncompilable.el" preexisting-files))
(eldev--test-run nil ((eldev--test-on-demand-to-loading-mode-option on-demand) "compile")
(eldev--test-assert-files project-dir preexisting-files "project-j-autoloads.el" "project-j.elc" "project-j-advanced.elc")
(should (= exit-code 0)))))


(ert-deftest eldev-compile-test-files-1 ()
(eldev--test-without-files "project-a" ("test/project-a.elc")
Expand Down
11 changes: 11 additions & 0 deletions test/project-j/project-j-uncompilable.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
;; -*- lexical-binding: t; no-byte-compile: t -*-

;; Usage of `no-byte-compile' is not an accident: testing that such files are handled
;; correctly too.

;;;###autoload
(defun project-j-never-compiled-hello ()
;; Not requiring anything for this function: it must be autoloaded.
(project-i-hello))

(provide 'project-j-uncompilable)

0 comments on commit 341ac1f

Please sign in to comment.