Skip to content

Commit

Permalink
[Build] Compile .el files individually.
Browse files Browse the repository at this point in the history
Fixes #657
  • Loading branch information
Alexander-Miller committed Apr 29, 2020
1 parent d257cef commit 10c96c9
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 24 deletions.
46 changes: 42 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,57 @@ EMACS ?= emacs
NO_LOAD_WARNINGS = --eval "(defvar treemacs-no-load-time-warnings t)"
SRC_DIR = src/elisp
EXTRA_DIR = src/extra
EMACSFLAGS = -Q -batch -L $(SRC_DIR) -L $(EXTRA_DIR) $(NO_LOAD_WARNINGS)
COMPILE_COMMAND = -f batch-byte-compile $(SRC_DIR)/*.el $(EXTRA_DIR)/*.el
EMACSFLAGS = -Q -batch -L $(SRC_DIR) $(NO_LOAD_WARNINGS)
COMPILE_COMMAND = -f batch-byte-compile
CHECKDOC_COMMAND = -l "test/checkdock.el"
LINT_DIR = /tmp/treemacs
LINT_FLAG = --eval "(setq byte-compile-dest-file-function (lambda (f) (concat \"$(LINT_DIR)\" (file-name-nondirectory f) \"c\")))"
TEST_COMMAND = buttercup -L $(SRC_DIR) -L $(EXTRA_DIR) $(NO_LOAD_WARNINGS)

ELS = $(SRC_DIR)/treemacs.el
ELS += $(SRC_DIR)/treemacs-async.el
ELS += $(SRC_DIR)/treemacs-bookmarks.el
ELS += $(SRC_DIR)/treemacs-compatibility.el
ELS += $(SRC_DIR)/treemacs-core-utils.el
ELS += $(SRC_DIR)/treemacs-customization.el
ELS += $(SRC_DIR)/treemacs-diagnostics.el
ELS += $(SRC_DIR)/treemacs-dom.el
ELS += $(SRC_DIR)/treemacs-extensions.el
ELS += $(SRC_DIR)/treemacs-faces.el
ELS += $(SRC_DIR)/treemacs-icons.el
ELS += $(SRC_DIR)/treemacs-interface.el
ELS += $(SRC_DIR)/treemacs-filewatch-mode.el
ELS += $(SRC_DIR)/treemacs-follow-mode.el
ELS += $(SRC_DIR)/treemacs-fringe-indicator.el
ELS += $(SRC_DIR)/treemacs-icons.el
ELS += $(SRC_DIR)/treemacs-logging.el
ELS += $(SRC_DIR)/treemacs-macros.el
ELS += $(SRC_DIR)/treemacs-mode.el
ELS += $(SRC_DIR)/treemacs-mouse-interface.el
ELS += $(SRC_DIR)/treemacs-persistence.el
ELS += $(SRC_DIR)/treemacs-rendering.el
ELS += $(SRC_DIR)/treemacs-scope.el
ELS += $(SRC_DIR)/treemacs-tag-follow-mode.el
ELS += $(SRC_DIR)/treemacs-tags.el
ELS += $(SRC_DIR)/treemacs-tags.el
ELS += $(SRC_DIR)/treemacs-themes.el
ELS += $(SRC_DIR)/treemacs-visuals.el
ELS += $(SRC_DIR)/treemacs-workspaces.el
ELS += $(EXTRA_DIR)/treemacs-evil.el
ELS += $(EXTRA_DIR)/treemacs-icons-dired.el
ELS += $(EXTRA_DIR)/treemacs-persp.el
ELS += $(EXTRA_DIR)/treemacs-projectile.el
ELCS = $(ELS:.el=.elc)

.PHONY: test compile checkdoc clean lint prepare clean-start .prepare-lint

.ONESHELL:

compile: prepare
@$(CASK) exec $(EMACS) $(EMACSFLAGS) $(COMPILE_COMMAND)
%.elc: %.el
@printf "Compiling $<\n"
$(CASK) exec $(EMACS) $(EMACSFLAGS) $(COMPILE_COMMAND) $<

compile: prepare $(ELCS)

.cask: Cask
@echo Updating external dependencies...
Expand Down
40 changes: 21 additions & 19 deletions src/elisp/treemacs-icons.el
Original file line number Diff line number Diff line change
Expand Up @@ -46,27 +46,29 @@
;; Since it is a marker in the treemacs buffer it is important for it to be reset whenever it might
;; become invalid.

(defvar treemacs--not-selected-icon-background
(pcase (face-attribute 'default :background nil t)
('unspecified
(prog1 "#2d2d31"
(unless (boundp 'treemacs-no-load-time-warnings)
(message "[Treemacs] Warning: coudn't find default background color for icons, falling back on #2d2d31."))))
('unspecified-bg
(prog1 "#2d2d31"
(unless (boundp 'treemacs-no-load-time-warnings)
(message "[Treemacs] Warning: background color is unspecified, icons will likely look wrong. Falling back on #2d2d31."))))
(other other))
(eval-and-compile
(defvar treemacs--not-selected-icon-background
(pcase (face-attribute 'default :background nil t)
('unspecified
(prog1 "#2d2d31"
(unless (boundp 'treemacs-no-load-time-warnings)
(message "[Treemacs] Warning: coudn't find default background color for icons, falling back on #2d2d31."))))
('unspecified-bg
(prog1 "#2d2d31"
(unless (boundp 'treemacs-no-load-time-warnings)
(message "[Treemacs] Warning: background color is unspecified, icons will likely look wrong. Falling back on #2d2d31."))))
(other other)))
"Background for non-selected icons.")

(defvar treemacs--selected-icon-background
(-let [bg (face-attribute 'hl-line :background nil t)]
(if (memq bg '(unspecified unspecified-b))
(prog1 treemacs--not-selected-icon-background
(unless (boundp 'treemacs-no-load-time-warnings)
(message "[Treemacs] Warning: couldn't find hl-line-mode's background color for icons, falling back on %s."
treemacs--not-selected-icon-background)))
bg))
(eval-and-compile
(defvar treemacs--selected-icon-background
(-let [bg (face-attribute 'hl-line :background nil t)]
(if (memq bg '(unspecified unspecified-b))
(prog1 treemacs--not-selected-icon-background
(unless (boundp 'treemacs-no-load-time-warnings)
(message "[Treemacs] Warning: couldn't find hl-line-mode's background color for icons, falling back on %s."
treemacs--not-selected-icon-background)))
bg)))
"Background for selected icons.")

(define-inline treemacs--set-img-property (image property value)
Expand Down
5 changes: 4 additions & 1 deletion test/checkdock.el
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
;; Based on https://github.com/flycheck/flycheck/blob/master/maint/flycheck-checkdoc.el
;;; -*- lexical-binding: t -*-
;;; Based on https://github.com/flycheck/flycheck/blob/master/maint/flycheck-checkdoc.el

(require 'checkdoc)
(require 'dash)
Expand All @@ -8,6 +9,8 @@
(directory-files "./src/extra" :full ".el")))

(defun checkdoc-buffer (filename)
;; output only /src/elisp/filename.el as when compiling
(message "Checkdoc %s" (substring filename (1+ (s-index-of "/src" filename))))
(with-temp-buffer
;; Visit the file to make sure that the filename is set, as some checkdoc
;; lints only apply for buffers with filenames
Expand Down

0 comments on commit 10c96c9

Please sign in to comment.