Skip to content

Commit

Permalink
Compile built-in libs
Browse files Browse the repository at this point in the history
  • Loading branch information
JAremko committed Jan 18, 2021
1 parent 9f1f074 commit 787820a
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
35 changes: 35 additions & 0 deletions core/core-compilation.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;; core-compilation.el --- Spacemacs Core File
;;
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
;;
;; Author: Eugene "JAremko" Yaremenko <[email protected]>
;; 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)
4 changes: 4 additions & 0 deletions core/core-spacemacs.el
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
(require 'core-transient-state)
(require 'core-use-package-ext)
(require 'core-spacebind)
(require 'core-compilation)

(defgroup spacemacs nil
"Spacemacs customizations."
Expand Down Expand Up @@ -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))

Expand Down
4 changes: 2 additions & 2 deletions early-init.el
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 787820a

Please sign in to comment.