-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathMakefile
More file actions
150 lines (123 loc) · 5.91 KB
/
Makefile
File metadata and controls
150 lines (123 loc) · 5.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
EMACS ?= emacs
XDG_CACHE_HOME ?= $(HOME)/.cache
MELPAZOID_DIR ?= $(XDG_CACHE_HOME)/melpazoid
EVIL_DIR ?= $(XDG_CACHE_HOME)/evil
ELC := lisp/ghostel.elc lisp/ghostel-debug.elc lisp/ghostel-compile.elc \
lisp/ghostel-eshell.elc \
extensions/evil-ghostel/evil-ghostel.elc
.PHONY: all build test test-native test-zig test-all test-evil lint melpazoid melpazoid-ghostel melpazoid-evil-ghostel byte-compile docquotes bench bench-quick bench-e2e bench-tui-partial clean regen-terminfo
all: build test-all test-evil lint
build:
zig build -Doptimize=ReleaseFast -Dcpu=baseline
test-zig:
zig build test
# Pattern rule: rebuild .elc whenever its .el source is newer.
# Make's timestamp tracking keeps the byte-compiled files in sync, so
# test targets never load stale .elc (Emacs prefers .elc over .el
# even when the source is newer, which silently masks edits).
lisp/%.elc: lisp/%.el
$(EMACS) --batch -Q -L lisp --eval "(setq byte-compile-error-on-warn t)" -f batch-byte-compile $<
# Extension packages depend on third-party libraries; reuse the evil
# checkout that `test-evil' manages.
$(EVIL_DIR):
git clone --depth 1 https://github.com/emacs-evil/evil.git "$@"
extensions/evil-ghostel/%.elc: extensions/evil-ghostel/%.el | $(EVIL_DIR)
$(EMACS) --batch -Q -L "$(EVIL_DIR)" -L lisp -L extensions/evil-ghostel \
--eval "(setq byte-compile-error-on-warn t)" -f batch-byte-compile $<
test: $(ELC)
$(EMACS) --batch -Q -L lisp -l ert -l test/ghostel-test.el -f ghostel-test-run-elisp
test-native: build $(ELC)
$(EMACS) --batch -Q -L lisp -l ert -l test/ghostel-test.el -f ghostel-test-run-native
test-all: test test-zig test-native
test-evil: build $(ELC) | $(EVIL_DIR)
$(EMACS) --batch -Q -L "$(EVIL_DIR)" -L lisp -L extensions/evil-ghostel \
-l ert -l test/evil-ghostel-test.el -f evil-ghostel-test-run
byte-compile: $(ELC)
lint: byte-compile package-lint checkdoc docquotes
package-lint:
$(EMACS) --batch -Q \
--eval "(package-initialize)" \
--eval "(require 'package-lint)" \
-f package-lint-batch-and-exit \
lisp/ghostel.el extensions/evil-ghostel/evil-ghostel.el
checkdoc:
$(EMACS) --batch -Q \
--eval "(require 'checkdoc)" \
--eval "(let ((sentence-end-double-space nil) \
(checkdoc-proper-noun-list nil) \
(checkdoc-verb-check-experimental-flag nil) \
(ok t)) \
(dolist (f '(\"lisp/ghostel.el\" \"lisp/ghostel-debug.el\" \"lisp/ghostel-compile.el\" \"lisp/ghostel-eshell.el\" \"extensions/evil-ghostel/evil-ghostel.el\" \"test/ghostel-test.el\")) \
(ignore-errors (kill-buffer \"*Warnings*\")) \
(let ((inhibit-message t)) \
(checkdoc-file f)) \
(when (get-buffer \"*Warnings*\") \
(setq ok nil) \
(with-current-buffer \"*Warnings*\" \
(message \"%s\" (buffer-string))))) \
(unless ok (kill-emacs 1)))"
# Mirrors melpazoid's "Only use back/front quotes to link to top-level
# elisp symbols" check, widened to also catch identifiers with
# underscores like INSIDE_EMACS — env-var and macro-style names that
# melpazoid's stricter [A-Z]+ regex skips.
docquotes:
$(EMACS) --batch -Q \
--eval "(let ((ok t)) \
(dolist (f '(\"lisp/ghostel.el\" \"lisp/ghostel-debug.el\" \"lisp/ghostel-compile.el\" \"lisp/ghostel-eshell.el\" \"extensions/evil-ghostel/evil-ghostel.el\")) \
(with-temp-buffer \
(insert-file-contents f) \
(setq case-fold-search nil) \
(goto-char (point-min)) \
(while (re-search-forward \"\`[A-Z_]+'\" nil t) \
(setq ok nil) \
(message \"%s:%d:%d: Only use back/front quotes to link to top-level elisp symbols (%s)\" \
f (line-number-at-pos) \
(1+ (- (match-beginning 0) (line-beginning-position))) \
(match-string 0))))) \
(unless ok (kill-emacs 1)))"
melpazoid: melpazoid-ghostel melpazoid-evil-ghostel
melpazoid-ghostel:
@if [ ! -d "$(MELPAZOID_DIR)" ]; then \
git clone https://github.com/riscy/melpazoid.git "$(MELPAZOID_DIR)"; \
fi
RECIPE='(ghostel :fetcher github :repo "dakra/ghostel" :files (:defaults "etc" "src" "vendor" "build.zig" "build.zig.zon" "symbols.map"))' \
LOCAL_REPO=$(CURDIR) \
make -C "$(MELPAZOID_DIR)"
melpazoid-evil-ghostel:
@if [ ! -d "$(MELPAZOID_DIR)" ]; then \
git clone https://github.com/riscy/melpazoid.git "$(MELPAZOID_DIR)"; \
fi
RECIPE='(evil-ghostel :fetcher github :repo "dakra/ghostel" :files ("extensions/evil-ghostel/evil-ghostel.el"))' \
LOCAL_REPO=$(CURDIR) \
make -C "$(MELPAZOID_DIR)"
bench:
bash bench/run-bench.sh
bench-quick:
bash bench/run-bench.sh --quick
bench-e2e:
bash bench/run-bench.sh --e2e
bench-tui-partial:
$(EMACS) --batch -Q -L lisp -l bench/ghostel-bench.el \
--eval '(progn (setq ghostel-bench-include-vterm nil ghostel-bench-include-eat nil ghostel-bench-include-term nil) (ghostel-bench--load-backends) (ghostel-bench--run-tui-partial-scenarios))'
clean:
rm -f ghostel-module.dylib ghostel-module.so
rm -f $(ELC)
rm -rf zig-out .zig-cache
# Maintainer-only: regenerate the bundled compiled terminfo from
# `etc/terminfo/xterm-ghostty.terminfo'. Run after bumping libghostty
# (the source file should be re-extracted from a fresh Ghostty install
# via `infocmp -x xterm-ghostty') and commit the resulting binaries.
# `tic' on macOS emits the BSD hashed-dir layout (78/, 67/); the
# binary file format is identical to Linux ncurses, so we mirror the
# compiled entries into the Linux layout (x/, g/) by copying.
regen-terminfo:
rm -rf etc/terminfo/x etc/terminfo/g etc/terminfo/78 etc/terminfo/67
tic -x -o etc/terminfo/ etc/terminfo/xterm-ghostty.terminfo
@if [ -d etc/terminfo/78 ]; then \
mkdir -p etc/terminfo/x etc/terminfo/g; \
cp etc/terminfo/78/xterm-ghostty etc/terminfo/x/xterm-ghostty; \
cp etc/terminfo/67/ghostty etc/terminfo/g/ghostty; \
fi
@TERMINFO=$(CURDIR)/etc/terminfo infocmp xterm-ghostty >/dev/null \
|| (echo "ERROR: regenerated terminfo failed to round-trip"; exit 1)
@find etc/terminfo -type f | sort