Force straight to byte-compile packages in same session
Straight (on its develop branch) byte compiles packages in a child process, isolated from the current session. This is a sensible approach and I applaud it, but there's a problem: Some packages don't load their compile-time dependencies at compile-time, causing errors *at* compile-time. They unwittingly rely on the fact that package.el compiles them in the same session as their dependencies, which indirectly loads their macros for them. I can't depend on package authors to do the right thing, but I can force straight to revert to the old approach.
This commit is contained in:
parent
95a603733a
commit
628f0a930f
1 changed files with 17 additions and 38 deletions
|
@ -751,45 +751,24 @@ See the docstrings of `defalias' and `make-obsolete' for more details."
|
|||
`(progn (defalias ,obsolete-name ,current-name ,docstring)
|
||||
(make-obsolete ,obsolete-name ,current-name ,when)))
|
||||
|
||||
(defadvice! doom--fix-wrong-number-of-args-during-byte-compile (recipe)
|
||||
(defadvice! doom--byte-compile-in-same-session-a (recipe)
|
||||
"Straight recompiles packages from an Emacs child process. This is sensible,
|
||||
but many packages don't properly load their macro dependencies, causing errors,
|
||||
which we can't possibly police, so I revert straight to its old strategy of
|
||||
compiling in the same session."
|
||||
:override #'straight--build-compile
|
||||
(let* ((package (plist-get recipe :package))
|
||||
(dir (straight--build-dir package))
|
||||
(program (concat invocation-directory invocation-name))
|
||||
(args
|
||||
`("-Q" "-L" ,dir
|
||||
,@(apply #'append
|
||||
(mapcar (lambda (d)
|
||||
(let ((d (straight--build-dir d)))
|
||||
(when (file-exists-p d) (list "-L" d))))
|
||||
(straight--get-dependencies package)))
|
||||
"--batch"
|
||||
"--eval"
|
||||
,(prin1-to-string
|
||||
'(progn
|
||||
(defmacro define-obsolete-face-alias (obsolete-face current-face &optional when)
|
||||
`(progn (put ,obsolete-face 'face-alias ,current-face)
|
||||
(put ,obsolete-face 'obsolete-face (or (purecopy ,when) t))))
|
||||
(defmacro define-obsolete-function-alias (obsolete-name current-name &optional when docstring)
|
||||
`(progn (defalias ,obsolete-name ,current-name ,docstring)
|
||||
(make-obsolete ,obsolete-name ,current-name ,when)))
|
||||
(defmacro define-obsolete-variable-alias (obsolete-name current-name &optional when docstring)
|
||||
`(progn (defvaralias ,obsolete-name ,current-name ,docstring)
|
||||
(dolist (prop '(saved-value saved-variable-comment))
|
||||
(and (get ,obsolete-name prop)
|
||||
(null (get ,current-name prop))
|
||||
(put ,current-name prop (get ,obsolete-name prop))))
|
||||
(make-obsolete-variable ,obsolete-name ,current-name ,when)))))
|
||||
"--eval"
|
||||
,(format "(byte-recompile-directory %S 0 'force)" dir))))
|
||||
(when straight-byte-compilation-buffer
|
||||
(with-current-buffer (get-buffer-create straight-byte-compilation-buffer)
|
||||
(insert "\n$ " (replace-regexp-in-string
|
||||
"\\(-L [^z-a]*? \\)"
|
||||
"\\1\\\\ \n "
|
||||
(string-join `(,program ,@args) " "))
|
||||
"\n")))
|
||||
(apply #'call-process program nil straight-byte-compilation-buffer nil args))))
|
||||
(straight--with-plist recipe (package)
|
||||
;; These two `let' forms try very, very hard to make byte-compilation an
|
||||
;; invisible process. Lots of packages have byte-compile warnings; I
|
||||
;; don't need to know about them and neither do straight.el users.
|
||||
(letf! (;; Prevent Emacs from asking the user to save all their
|
||||
;; files before compiling.
|
||||
(#'save-some-buffers #'ignore))
|
||||
(quiet!
|
||||
;; Note that there is in fact no `byte-compile-directory' function.
|
||||
(byte-recompile-directory
|
||||
(straight--build-dir package)
|
||||
0 'force))))))
|
||||
|
||||
(provide 'core-lib)
|
||||
;;; core-lib.el ends here
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue