diff --git a/core/core-compilation.el b/core/core-compilation.el new file mode 100644 index 000000000000..265f048025ba --- /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 8c785beca6ba..0df55597ca5e 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 07ff422528f3..cf92d7ba71e1 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