From 54a084fed7e1051339ce61561d61af54d269c94e Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 26 Jul 2024 03:29:26 -0400 Subject: [PATCH] fix(cli): some package files not being byte-compiled Fix: #7707 Ref: radian-software/straight.el#1132 --- lisp/cli/packages.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lisp/cli/packages.el b/lisp/cli/packages.el index f9c2a35b6..adc561aee 100644 --- a/lisp/cli/packages.el +++ b/lisp/cli/packages.el @@ -830,5 +830,37 @@ However, in batch mode, print to stdout instead of stderr." (error "Package was not properly cloned due to a connection failure, please try again later") (signal (car e) (cdr e)))))) +;; HACK: Fix an issue where straight wasn't byte-compiling some packages (or +;; some files in packages) due to missing (invisible) dependencies. +(defadvice! doom-cli--straight-byte-compile-a (recipe) + "See https://github.com/radian-software/straight.el/pull/1132" + :override #'straight--build-compile + (let* ((pkg (plist-get recipe :package)) + (dir (straight--build-dir pkg)) + (emacs (concat invocation-directory invocation-name)) + (buffer straight-byte-compilation-buffer) + (deps + (let (tmp) + (dolist (dep (straight--flatten (straight-dependencies pkg)) tmp) + (let ((build-dir (straight--build-dir dep))) + (when (file-exists-p build-dir) + (push build-dir tmp)))))) + (print-circle nil) + (print-length nil) + (program + (format "%S" `(let ((default-directory ,(straight--build-dir)) + (lp load-path)) + (setq load-path (list default-directory)) + (normal-top-level-add-subdirs-to-load-path) + (setq load-path (append '(,dir) ',deps load-path lp)) + (byte-recompile-directory ,dir 0 'force)))) + (args (list "-Q" "--batch" "--eval" program))) + (when buffer + (with-current-buffer (get-buffer-create buffer) + (insert (format "\n$ %s %s \\\n %S\n" emacs + (string-join (butlast args) " ") + program)))) + (apply #'call-process `(,emacs nil ,buffer nil ,@args)))) + (provide 'doom-cli-packages) ;;; packages.el ends here