Optimize straight build step

Constant `(require 'comp nil t)` checks are quite slow on systems where the library isn't available, so only do it once.
This commit is contained in:
Henrik Lissner 2020-07-28 01:34:33 -04:00 committed by GitHub
parent d8af5c3cad
commit b9b987e1ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -134,8 +134,7 @@ list remains lean."
t))) t)))
(defun doom--eln-file-outdated-p (file) (defun doom--eln-file-outdated-p (file)
(when-let* (((require 'comp nil 'noerror)) (when-let* ((eln-file (comp-output-filename file))
(eln-file (comp-output-filename file))
(error-file (concat eln-file ".error"))) (error-file (concat eln-file ".error")))
(push eln-file doom--expected-eln-files) (push eln-file doom--expected-eln-files)
(cond ((file-exists-p eln-file) (cond ((file-exists-p eln-file)
@ -180,8 +179,8 @@ list remains lean."
else do else do
(let ((inhibit-message t)) (let ((inhibit-message t))
(sleep-for 0.1))) (sleep-for 0.1)))
;; HACK Write .error files for any missing files which still don't ;; HACK Write .error files for any missing files which still don't exist.
;; exist. We'll just assume there was some kind of error... ;; We'll just assume there was some kind of error...
(cl-loop for eln-file in doom--expected-eln-files (cl-loop for eln-file in doom--expected-eln-files
for error-file = (concat eln-file ".error") for error-file = (concat eln-file ".error")
unless (or (file-exists-p eln-file) unless (or (file-exists-p eln-file)
@ -259,21 +258,15 @@ declaration) or dependency thereof that hasn't already been."
;; Ensure packages with outdated files/bytecode are rebuilt ;; Ensure packages with outdated files/bytecode are rebuilt
(let ((build-dir (straight--build-dir package)) (let ((build-dir (straight--build-dir package))
(repo-dir (straight--repos-dir local-repo))) (repo-dir (straight--repos-dir local-repo)))
(and (or (file-newer-than-file-p repo-dir build-dir) (and (not (plist-get recipe :no-build))
(or (file-newer-than-file-p repo-dir build-dir)
(file-exists-p (straight--modified-dir (or local-repo package))) (file-exists-p (straight--modified-dir (or local-repo package)))
;; Doesn't make sense to compare el and elc files (cl-loop with want-byte = (straight--byte-compile-package-p recipe)
;; when the former isn't a symlink to their source. with want-native = (if (require 'comp nil t) (straight--native-compile-package-p recipe))
(when straight-use-symlinks for file in (doom-files-in build-dir :match "\\.el$" :full t)
(cl-loop for file in (doom-files-in build-dir :match "\\.el$" :full t) if (or (if want-byte (doom--elc-file-outdated-p file))
with want-byte = (straight--byte-compile-package-p recipe) (if want-native (doom--eln-file-outdated-p file)))
with want-native = (straight--native-compile-package-p recipe) return t))
with outdated = nil
if (and (file-symlink-p file)
(or (and want-byte (doom--elc-file-outdated-p file))
(and want-native (doom--eln-file-outdated-p file))))
do (setq outdated t)
finally return outdated)))
(not (plist-get recipe :no-build))
(puthash package t straight--packages-to-rebuild)))) (puthash package t straight--packages-to-rebuild))))
(straight-use-package (intern package)))) (straight-use-package (intern package))))
(progn (progn
@ -283,6 +276,7 @@ declaration) or dependency thereof that hasn't already been."
nil)))) nil))))
(defun doom-cli-packages-update () (defun doom-cli-packages-update ()
"Updates packages." "Updates packages."
(doom-initialize-packages) (doom-initialize-packages)