From 787820a7add302dd0930277b88e77b5214adef2c Mon Sep 17 00:00:00 2001 From: JAremko Date: Mon, 18 Jan 2021 16:26:45 +0200 Subject: [PATCH] Compile built-in libs --- core/core-compilation.el | 35 +++++++++++++++++++++++++++++++++++ core/core-spacemacs.el | 4 ++++ early-init.el | 4 ++-- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 core/core-compilation.el diff --git a/core/core-compilation.el b/core/core-compilation.el new file mode 100644 index 000000000..265f04802 --- /dev/null +++ b/core/core-compilation.el @@ -0,0 +1,35 @@ +;;; core-compilation.el --- Spacemacs Core File +;; +;; Copyright (c) 2012-2021 Sylvain Benner & Contributors +;; +;; Author: Eugene "JAremko" Yaremenko +;; URL: https://github.com/syl20bnr/spacemacs +;; +;; This file is not part of GNU Emacs. +;; +;;; License: GPLv3 + +(defconst spacemacs-compiled-files + '(;; Built-in libs that we changed + "core/libs/forks/load-env-vars.el" + ;; Rest of built-in libs. + "core/libs/dash.el" + "core/libs/ht.el" + "core/libs/ido-vertical-mode.el" + "core/libs/package-build-badges.el" + "core/libs/package-build.el" + "core/libs/package-recipe-mode.el" + "core/libs/page-break-lines.el" + "core/libs/quelpa.el" + "core/libs/spinner.el") + "List of Spacemacs files that should be compiled. +File paths are relative to the `user-emacs-directory'.") + +(defun spacemacs//ensure-compilation (files) + "Make sure that the .el FILES are compiled." + (dolist (file files) + (let ((fbn (file-name-sans-extension (file-truename file)))) + (unless (file-exists-p (concat fbn ".elc")) + (byte-compile-file (concat fbn ".el")))))) + +(provide 'core-compilation) diff --git a/core/core-spacemacs.el b/core/core-spacemacs.el index 8c785beca..0df55597c 100644 --- a/core/core-spacemacs.el +++ b/core/core-spacemacs.el @@ -33,6 +33,7 @@ (require 'core-transient-state) (require 'core-use-package-ext) (require 'core-spacebind) +(require 'core-compilation) (defgroup spacemacs nil "Spacemacs customizations." @@ -158,6 +159,9 @@ the final step of executing code in `emacs-startup-hook'.") (if (fboundp 'dotspacemacs/user-env) (dotspacemacs/call-user-env) (spacemacs/load-spacemacs-env)) + ;; Ensure that `spacemacs-compiled-files' are compiled. + (let ((default-directory user-emacs-directory)) + (spacemacs//ensure-compilation spacemacs-compiled-files)) ;; install the dotfile if required (dotspacemacs/maybe-install-dotfile)) diff --git a/early-init.el b/early-init.el index 07ff42252..cf92d7ba7 100644 --- a/early-init.el +++ b/early-init.el @@ -25,8 +25,8 @@ ;; Auto compilation. (setq load-prefer-newer t) -(load (concat user-emacs-directory "core/libs/packed")) -(load (concat user-emacs-directory "core/libs/auto-compile")) +(load (concat user-emacs-directory "core/libs/packed") nil t) +(load (concat user-emacs-directory "core/libs/auto-compile") nil t) (auto-compile-on-load-mode) (auto-compile-on-save-mode) ;;; early-init.el ends here