Don't error out if no targets for byte-compilation could be found

This commit is contained in:
Henrik Lissner 2018-04-04 08:14:06 -04:00
parent b98e26856d
commit a47d76f5f1
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395

View file

@ -797,47 +797,47 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files."
else if (file-exists-p target) else if (file-exists-p target)
collect target collect target
finally do (setq argv nil))) finally do (setq argv nil)))
(unless compile-targets (if (not compile-targets)
(error "No targets to compile")) (message "No targets to compile")
(condition-case ex (condition-case ex
(let ((use-package-expand-minimally t)) (let ((use-package-expand-minimally t))
(push (expand-file-name "init.el" doom-emacs-dir) compile-targets) (push (expand-file-name "init.el" doom-emacs-dir) compile-targets)
(dolist (target (cl-delete-duplicates (mapcar #'file-truename compile-targets) :test #'string=)) (dolist (target (cl-delete-duplicates (mapcar #'file-truename compile-targets) :test #'string=))
(when (or (not recompile-p) (when (or (not recompile-p)
(let ((elc-file (byte-compile-dest-file target))) (let ((elc-file (byte-compile-dest-file target)))
(and (file-exists-p elc-file) (and (file-exists-p elc-file)
(file-newer-than-file-p file elc-file)))) (file-newer-than-file-p file elc-file))))
(let ((result (if (doom-packages--read-if-cookies target) (let ((result (if (doom-packages--read-if-cookies target)
(byte-compile-file target) (byte-compile-file target)
'no-byte-compile)) 'no-byte-compile))
(short-name (if (file-in-directory-p target doom-emacs-dir) (short-name (if (file-in-directory-p target doom-emacs-dir)
(file-relative-name target doom-emacs-dir) (file-relative-name target doom-emacs-dir)
(abbreviate-file-name target)))) (abbreviate-file-name target))))
(cl-incf (cl-incf
(cond ((eq result 'no-byte-compile) (cond ((eq result 'no-byte-compile)
(message! (dark (white "⚠ Ignored %s" short-name))) (message! (dark (white "⚠ Ignored %s" short-name)))
total-noop) total-noop)
((null result) ((null result)
(message! (red "✕ Failed to compile %s" short-name)) (message! (red "✕ Failed to compile %s" short-name))
total-fail) total-fail)
(t (t
(message! (green "✓ Compiled %s" short-name)) (message! (green "✓ Compiled %s" short-name))
(quiet! (load target t t)) (quiet! (load target t t))
total-ok)))))) total-ok))))))
(message! (message!
(bold (bold
(color (if (= total-fail 0) 'green 'red) (color (if (= total-fail 0) 'green 'red)
"%s %s file(s) %s" "%s %s file(s) %s"
(if recompile-p "Recompiled" "Compiled") (if recompile-p "Recompiled" "Compiled")
(format "%d/%d" total-ok (- (length compile-targets) total-noop)) (format "%d/%d" total-ok (- (length compile-targets) total-noop))
(format "(%s ignored)" total-noop))))) (format "(%s ignored)" total-noop)))))
(error (error
(message! (red "\n%%s\n\n%%s\n\n%%s") (message! (red "\n%%s\n\n%%s\n\n%%s")
"There were breaking errors." "There were breaking errors."
(error-message-string ex) (error-message-string ex)
"Reverting changes...") "Reverting changes...")
(doom//clean-byte-compiled-files) (doom//clean-byte-compiled-files)
(message! (green "Finished (nothing was byte-compiled)")))))))) (message! (green "Finished (nothing was byte-compiled)")))))))))
(defun doom//byte-compile-core (&optional recompile-p) (defun doom//byte-compile-core (&optional recompile-p)
"Byte compile the core Doom files. "Byte compile the core Doom files.