This repository has been archived on 2024-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
spacemacs/core/core-compilation.el

72 lines
2.6 KiB
EmacsLisp
Raw Normal View History

;;; core-compilation.el --- Spacemacs Core File -*- no-byte-compile: t -*-
2021-01-18 14:26:45 +00:00
;;
;; Copyright (c) 2012-2021 Sylvain Benner & Contributors
;;
;; Author: Eugene "JAremko" Yaremenko <w3techplayground@gmail.com>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
2021-01-25 14:56:36 +00:00
(require 'cl-lib)
(require 'subr-x)
(defvar spacemacs--last-emacs-version ""
"This variable is set during Emacs initialization to its version.")
(defconst spacemacs--last-emacs-version-file
(expand-file-name (concat spacemacs-cache-directory "last-emacs-version"))
"File that sets `spacemacs--last-emacs-version' variable.")
2021-01-25 14:56:36 +00:00
(defconst spacemacs--compiled-files
2021-01-18 14:26:45 +00:00
'(;; Built-in libs that we changed
"core/libs/forks/load-env-vars.el"
"core/libs/forks/spacemacs-ht.el"
2021-01-18 14:26:45 +00:00
;; Rest of built-in libs.
"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.
2021-01-24 13:44:57 +00:00
File paths are relative to the `spacemacs-start-directory'.")
2021-01-18 14:26:45 +00:00
2021-01-20 00:55:18 +00:00
(defun spacemacs//ensure-byte-compilation (files)
"Make sure that elisp FILES are byte-compiled."
2021-01-18 14:26:45 +00:00
(dolist (file files)
2021-01-20 00:55:18 +00:00
(let ((fbp (file-name-sans-extension (file-truename file))))
2021-01-25 14:56:36 +00:00
(unless (file-exists-p (concat fbp ".elc"))
(byte-compile-file (concat fbp ".el"))))))
2021-01-18 14:26:45 +00:00
2021-01-25 01:06:28 +00:00
(defun spacemacs//remove-byte-compiled-files (files)
"Remove .elc files corresponding to the source FILES."
(dolist (file files)
2021-01-31 19:15:20 +00:00
(let ((file-elc (thread-last file
(file-truename)
(file-name-sans-extension)
(format "%s.elc"))))
(when (file-exists-p file-elc)
(delete-file file-elc)))))
2021-01-25 01:06:28 +00:00
2021-01-31 07:20:42 +00:00
(defun spacemacs//contains-newer-than-byte-compiled-p (files)
"Return true if any file in FILES is newer than its byte-compiled version."
(cl-dolist (file files)
(let* ((file-el (file-truename file))
(file-elc (thread-last file-el
(file-name-sans-extension)
(format "%s.elc"))))
(when (file-newer-than-file-p file-el file-elc)
(cl-return t)))))
2021-01-25 14:56:36 +00:00
(defun spacemacs//update-last-emacs-version ()
"Update `spacemacs--last-emacs-version' and its saved value."
(with-temp-file spacemacs--last-emacs-version-file
(insert (format "(setq spacemacs--last-emacs-version %S)"
(setq spacemacs--last-emacs-version emacs-version)))
(make-directory (file-name-directory spacemacs--last-emacs-version-file)
t)))
2021-01-18 14:26:45 +00:00
(provide 'core-compilation)