Refactor autoload generator bootstrappers
This commit is contained in:
parent
4a53f0818d
commit
4f676bd218
5 changed files with 48 additions and 63 deletions
|
@ -18,58 +18,51 @@ one wants that.")
|
||||||
(defvar autoload-timestamps)
|
(defvar autoload-timestamps)
|
||||||
(defvar generated-autoload-load-name)
|
(defvar generated-autoload-load-name)
|
||||||
|
|
||||||
(defun doom-cli-reload-autoloads (&optional type)
|
(defun doom-cli-reload-autoloads ()
|
||||||
"Reloads FILE (an autoload file), if it needs reloading.
|
"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
|
(defun doom-cli-reload-core-autoloads (&optional file)
|
||||||
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)
|
|
||||||
(print! (start "(Re)generating core autoloads..."))
|
(print! (start "(Re)generating core autoloads..."))
|
||||||
(print-group!
|
(print-group!
|
||||||
(and (print! (start "Generating core autoloads..."))
|
(let ((file (or file doom-autoload-file)))
|
||||||
(doom-cli--write-autoloads
|
(cl-check-type file string)
|
||||||
file (doom-cli--generate-autoloads
|
(and (print! (start "Generating core autoloads..."))
|
||||||
(cl-loop for dir in (append (list doom-core-dir)
|
(doom-cli--write-autoloads
|
||||||
(cdr (doom-module-load-path 'all-p))
|
file (doom-cli--generate-autoloads
|
||||||
(list doom-private-dir))
|
(cl-loop for dir in (append (list doom-core-dir)
|
||||||
if (doom-glob dir "autoload.el") collect it
|
(cdr (doom-module-load-path 'all-p))
|
||||||
if (doom-glob dir "autoload/*.el") append it)
|
(list doom-private-dir))
|
||||||
'scan))
|
if (doom-glob dir "autoload.el") collect it
|
||||||
(print! (start "Byte-compiling core autoloads file..."))
|
if (doom-glob dir "autoload/*.el") append it)
|
||||||
(doom-cli--byte-compile-file file)
|
'scan))
|
||||||
(print! (success "Generated %s")
|
(print! (start "Byte-compiling core autoloads file..."))
|
||||||
(relpath (byte-compile-dest-file file)
|
(doom-cli--byte-compile-file file)
|
||||||
doom-emacs-dir)))))
|
(print! (success "Generated %s")
|
||||||
|
(relpath (byte-compile-dest-file file)
|
||||||
|
doom-emacs-dir))))))
|
||||||
|
|
||||||
(defun doom-cli-reload-package-autoloads (file)
|
(defun doom-cli-reload-package-autoloads (&optional file)
|
||||||
(cl-check-type file string)
|
|
||||||
(print! (start "(Re)generating package autoloads..."))
|
(print! (start "(Re)generating package autoloads..."))
|
||||||
(print-group!
|
(print-group!
|
||||||
(doom-initialize-packages)
|
(doom-initialize-packages)
|
||||||
(and (print! (start "Generating package autoloads..."))
|
(let ((file (or file doom-package-autoload-file)))
|
||||||
(doom-cli--write-autoloads
|
(cl-check-type file string)
|
||||||
file
|
(and (print! (start "Generating package autoloads..."))
|
||||||
(doom-cli--generate-var-cache doom-autoload-cached-vars)
|
(doom-cli--write-autoloads
|
||||||
(doom-cli--generate-autoloads
|
file
|
||||||
(mapcar #'straight--autoloads-file
|
(doom-cli--generate-var-cache doom-autoload-cached-vars)
|
||||||
(cl-set-difference (hash-table-keys straight--build-cache)
|
(doom-cli--generate-autoloads
|
||||||
doom-autoload-excluded-packages
|
(mapcar #'straight--autoloads-file
|
||||||
:test #'string=))))
|
(cl-set-difference (hash-table-keys straight--build-cache)
|
||||||
(print! (start "Byte-compiling package autoloads file..."))
|
doom-autoload-excluded-packages
|
||||||
(doom-cli--byte-compile-file file)
|
:test #'string=))))
|
||||||
(print! (success "Generated %s")
|
(print! (start "Byte-compiling package autoloads file..."))
|
||||||
(relpath (byte-compile-dest-file file)
|
(doom-cli--byte-compile-file file)
|
||||||
doom-emacs-dir)))))
|
(print! (success "Generated %s")
|
||||||
|
(relpath (byte-compile-dest-file file)
|
||||||
|
doom-emacs-dir))))))
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
@ -223,6 +216,7 @@ it is nil, it will try to reload both."
|
||||||
(cl-remove-if-not #'file-readable-p files)
|
(cl-remove-if-not #'file-readable-p files)
|
||||||
(nreverse (delq nil autoloads)))
|
(nreverse (delq nil autoloads)))
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
|
(print! (debug "- Scanning %s") (relpath file doom-emacs-dir))
|
||||||
(if scan
|
(if scan
|
||||||
(doom-cli--generate-autoloads-buffer file)
|
(doom-cli--generate-autoloads-buffer file)
|
||||||
(insert-file-contents file))
|
(insert-file-contents 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
|
This excludes packages whose `package!' declaration contains a non-nil :freeze
|
||||||
or :ignore property."
|
or :ignore property."
|
||||||
(straight-check-all)
|
(straight-check-all)
|
||||||
(doom-cli-reload-autoloads 'core)
|
(doom-cli-reload-core-autoloads)
|
||||||
(when (doom-cli-packages-update)
|
(when (doom-cli-packages-update)
|
||||||
(doom-cli-reload-autoloads 'package))
|
(doom-cli-reload-package-autoloads))
|
||||||
t)
|
t)
|
||||||
|
|
||||||
(defcli! (build b)
|
(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
|
their elisp files are byte-compiled. This is especially necessary if you upgrade
|
||||||
Emacs (as byte-code is generally not forward-compatible)."
|
Emacs (as byte-code is generally not forward-compatible)."
|
||||||
(when (doom-cli-packages-build (not rebuild-p))
|
(when (doom-cli-packages-build (not rebuild-p))
|
||||||
(doom-cli-reload-autoloads 'package))
|
(doom-cli-reload-package-autoloads))
|
||||||
t)
|
t)
|
||||||
|
|
||||||
(defcli! (purge p)
|
(defcli! (purge p)
|
||||||
|
@ -46,7 +46,7 @@ list remains lean."
|
||||||
(not norepos-p)
|
(not norepos-p)
|
||||||
(not nobuilds-p)
|
(not nobuilds-p)
|
||||||
regraft-p)
|
regraft-p)
|
||||||
(doom-cli-reload-autoloads 'package))
|
(doom-cli-reload-package-autoloads))
|
||||||
t)
|
t)
|
||||||
|
|
||||||
;; (defcli! rollback () ; TODO doom rollback
|
;; (defcli! rollback () ; TODO doom rollback
|
||||||
|
|
|
@ -50,9 +50,9 @@
|
||||||
(require 'core-cli)
|
(require 'core-cli)
|
||||||
(doom-initialize 'force 'noerror)
|
(doom-initialize 'force 'noerror)
|
||||||
(doom-initialize-modules)
|
(doom-initialize-modules)
|
||||||
(doom-cli-reload-autoloads 'core)
|
(doom-cli-reload-core-autoloads)
|
||||||
(when (doom-cli-packages-install)
|
(when (doom-cli-packages-install)
|
||||||
(doom-cli-reload-autoloads 'package)))))
|
(doom-cli-reload-package-autoloads)))))
|
||||||
(unless (zerop status)
|
(unless (zerop status)
|
||||||
(error "Failed to bootstrap unit tests"))))
|
(error "Failed to bootstrap unit tests"))))
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
|
|
|
@ -18,7 +18,7 @@ following shell commands:
|
||||||
(doom-cli-upgrade doom-auto-accept force-p)
|
(doom-cli-upgrade doom-auto-accept force-p)
|
||||||
(doom-cli-execute "refresh")
|
(doom-cli-execute "refresh")
|
||||||
(when (doom-cli-packages-update)
|
(when (doom-cli-packages-update)
|
||||||
(doom-cli-reload-autoloads 'package)
|
(doom-cli-reload-package-autoloads)
|
||||||
t)))
|
t)))
|
||||||
(print! (success "Done! Restart Emacs for changes to take effect."))
|
(print! (success "Done! Restart Emacs for changes to take effect."))
|
||||||
(print! "Nothing to do. Doom is up-to-date!")))
|
(print! "Nothing to do. Doom is up-to-date!")))
|
||||||
|
|
|
@ -246,16 +246,7 @@ stale."
|
||||||
(file-exists-p doom-env-file))
|
(file-exists-p doom-env-file))
|
||||||
(doom-cli-reload-env-file 'force))
|
(doom-cli-reload-env-file 'force))
|
||||||
|
|
||||||
;; Ensures that no pre-existing state pollutes the generation of the new
|
(doom-cli-reload-core-autoloads)
|
||||||
;; 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)
|
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
(and (doom-cli-packages-install)
|
(and (doom-cli-packages-install)
|
||||||
|
@ -264,7 +255,7 @@ stale."
|
||||||
(setq success t))
|
(setq success t))
|
||||||
(and (doom-cli-packages-purge prune-p 'builds-p prune-p prune-p)
|
(and (doom-cli-packages-purge prune-p 'builds-p prune-p prune-p)
|
||||||
(setq success t)))
|
(setq success t)))
|
||||||
(doom-cli-reload-autoloads 'package)
|
(doom-cli-reload-package-autoloads)
|
||||||
(doom-cli-byte-compile nil 'recompile))
|
(doom-cli-byte-compile nil 'recompile))
|
||||||
t)))
|
t)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue