Refactor autoload generator bootstrappers

This commit is contained in:
Henrik Lissner 2020-01-01 13:31:40 -05:00
parent 4a53f0818d
commit 4f676bd218
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
5 changed files with 48 additions and 63 deletions

View file

@ -18,24 +18,16 @@ one wants that.")
(defvar autoload-timestamps)
(defvar generated-autoload-load-name)
(defun doom-cli-reload-autoloads (&optional type)
"Reloads FILE (an autoload file), if it needs reloading.
(defun doom-cli-reload-autoloads ()
"Reloads `doom-autoload-file' and `doom-package-autoload-file' files."
(doom-cli-reload-core-autoloads)
(doom-cli-reload-package-autoloads))
FILE should be one of `doom-autoload-file' or `doom-package-autoload-file'. If
it is nil, it will try to reload both."
(if type
(cond ((eq type 'core)
(doom-cli-reload-core-autoloads doom-autoload-file))
((eq type 'package)
(doom-cli-reload-package-autoloads doom-package-autoload-file))
((error "Invalid autoloads file: %s" type)))
(doom-cli-reload-autoloads 'core)
(doom-cli-reload-autoloads 'package)))
(defun doom-cli-reload-core-autoloads (file)
(cl-check-type file string)
(defun doom-cli-reload-core-autoloads (&optional file)
(print! (start "(Re)generating core autoloads..."))
(print-group!
(let ((file (or file doom-autoload-file)))
(cl-check-type file string)
(and (print! (start "Generating core autoloads..."))
(doom-cli--write-autoloads
file (doom-cli--generate-autoloads
@ -49,13 +41,14 @@ it is nil, it will try to reload both."
(doom-cli--byte-compile-file file)
(print! (success "Generated %s")
(relpath (byte-compile-dest-file file)
doom-emacs-dir)))))
doom-emacs-dir))))))
(defun doom-cli-reload-package-autoloads (file)
(cl-check-type file string)
(defun doom-cli-reload-package-autoloads (&optional file)
(print! (start "(Re)generating package autoloads..."))
(print-group!
(doom-initialize-packages)
(let ((file (or file doom-package-autoload-file)))
(cl-check-type file string)
(and (print! (start "Generating package autoloads..."))
(doom-cli--write-autoloads
file
@ -69,7 +62,7 @@ it is nil, it will try to reload both."
(doom-cli--byte-compile-file file)
(print! (success "Generated %s")
(relpath (byte-compile-dest-file file)
doom-emacs-dir)))))
doom-emacs-dir))))))
;;
@ -223,6 +216,7 @@ it is nil, it will try to reload both."
(cl-remove-if-not #'file-readable-p files)
(nreverse (delq nil autoloads)))
(with-temp-buffer
(print! (debug "- Scanning %s") (relpath file doom-emacs-dir))
(if scan
(doom-cli--generate-autoloads-buffer file)
(insert-file-contents file))

View file

@ -10,9 +10,9 @@ between HEAD and FETCH_HEAD. This can take a while.
This excludes packages whose `package!' declaration contains a non-nil :freeze
or :ignore property."
(straight-check-all)
(doom-cli-reload-autoloads 'core)
(doom-cli-reload-core-autoloads)
(when (doom-cli-packages-update)
(doom-cli-reload-autoloads 'package))
(doom-cli-reload-package-autoloads))
t)
(defcli! (build b)
@ -23,7 +23,7 @@ This ensures that all needed files are symlinked from their package repo and
their elisp files are byte-compiled. This is especially necessary if you upgrade
Emacs (as byte-code is generally not forward-compatible)."
(when (doom-cli-packages-build (not rebuild-p))
(doom-cli-reload-autoloads 'package))
(doom-cli-reload-package-autoloads))
t)
(defcli! (purge p)
@ -46,7 +46,7 @@ list remains lean."
(not norepos-p)
(not nobuilds-p)
regraft-p)
(doom-cli-reload-autoloads 'package))
(doom-cli-reload-package-autoloads))
t)
;; (defcli! rollback () ; TODO doom rollback

View file

@ -50,9 +50,9 @@
(require 'core-cli)
(doom-initialize 'force 'noerror)
(doom-initialize-modules)
(doom-cli-reload-autoloads 'core)
(doom-cli-reload-core-autoloads)
(when (doom-cli-packages-install)
(doom-cli-reload-autoloads 'package)))))
(doom-cli-reload-package-autoloads)))))
(unless (zerop status)
(error "Failed to bootstrap unit tests"))))
(with-temp-buffer

View file

@ -18,7 +18,7 @@ following shell commands:
(doom-cli-upgrade doom-auto-accept force-p)
(doom-cli-execute "refresh")
(when (doom-cli-packages-update)
(doom-cli-reload-autoloads 'package)
(doom-cli-reload-package-autoloads)
t)))
(print! (success "Done! Restart Emacs for changes to take effect."))
(print! "Nothing to do. Doom is up-to-date!")))

View file

@ -246,16 +246,7 @@ stale."
(file-exists-p doom-env-file))
(doom-cli-reload-env-file 'force))
;; Ensures that no pre-existing state pollutes the generation of the new
;; autoloads files.
(dolist (file (list doom-autoload-file doom-package-autoload-file))
(delete-file file)
(delete-file (byte-compile-dest-file file)))
(doom-initialize 'force 'noerror)
(doom-initialize-modules)
(doom-cli-reload-autoloads 'core)
(doom-cli-reload-core-autoloads)
(unwind-protect
(progn
(and (doom-cli-packages-install)
@ -264,7 +255,7 @@ stale."
(setq success t))
(and (doom-cli-packages-purge prune-p 'builds-p prune-p prune-p)
(setq success t)))
(doom-cli-reload-autoloads 'package)
(doom-cli-reload-package-autoloads)
(doom-cli-byte-compile nil 'recompile))
t)))