Add doom-get-package-alist

New function returns a list of (NAME . DESC) cons cells in the order
they were declared (in module packages.el files).

Fixes a load-order issue where autoloads from one package would depend
on the autoloads of another package, but was inserted into
doom-package-autoload-file *before* the depended package, causing
void-variable errors.

Also allows for a big refactor of the :plugins byte-compile target.
This commit is contained in:
Henrik Lissner 2018-06-14 00:04:12 +02:00
parent 08a4701774
commit 69c6e0b8fb
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 22 additions and 15 deletions

View file

@ -501,9 +501,9 @@ This should be run whenever your `doom!' block or update your packages."
(current-buffer))
(print! (green "✓ Cached package state"))
;; insert package autoloads
(dolist (spec package-alist)
(if-let* ((pkg (car spec))
(desc (cadr spec)))
(dolist (spec (doom-get-package-alist))
(if-let* ((pkg (car spec))
(desc (cdr spec)))
(unless (memq pkg doom-autoload-excluded-packages)
(let ((file (concat (package--autoloads-file-name desc) ".el")))
(when (file-exists-p file)
@ -561,18 +561,8 @@ If RECOMPILE-P is non-nil, only recompile out-of-date files."
(":core" (push doom-core-dir targets))
(":private" (push doom-private-dir targets))
(":plugins"
(doom-initialize-packages)
(let (visited)
(dolist (name (append doom-core-packages (mapcar #'car doom-packages)))
(unless (memq name visited)
(when-let* ((desc (cadr (assq name package-alist))))
(cl-loop for dep in (package--get-deps name)
if (and (not (memq dep visited))
(assq dep package-alist))
do (package--compile (cadr it))
and do (push dep visited))
(package--compile desc)
(push name visited)))))
(cl-loop for (name . desc) in (doom-get-package-alist)
do (package--compile desc))
(setq compile-plugins-p t
modules (delete ":plugins" modules)))
((pred file-directory-p)