-
Notifications
You must be signed in to change notification settings - Fork 151
/
Makefile
108 lines (92 loc) · 3.22 KB
/
Makefile
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
VERSION ?=
CMD ?=
EMACS ?= emacs
SHELL := bash
# The order is important for compilation.
for_compile := straight.el bootstrap.el install.el straight-x.el \
benchmark/straight-bench.el
for_checkdoc := straight.el
for_longlines := $(wildcard *.el *.md *.yml benchmark/*.el \
scripts/*.bash) Makefile
for_checkindent := $(wildcard *.el benchmark/*.el tests/*.el)
# excludes benchmarking, smoke and unit tests
.PHONY: all
all: clean compile test lint
.PHONY: help
help: ## Show this message
@echo "usage:" >&2
@grep -h "[#]# " $(MAKEFILE_LIST) | \
sed 's/^/ make /' | \
sed 's/:[^#]*[#]# /|/' | \
sed 's/%/LANG/' | \
column -t -s'|' >&2
.PHONY: lint
lint: compile checkdoc longlines toc ## Run all the linters
.PHONY: compile
compile: ## Byte-compile
@for file in $(for_compile); do \
echo "[compile] $$file" ;\
$(EMACS) -Q --batch -L . -f batch-byte-compile $$file 2>&1 \
| grep -v "^Wrote" \
| grep . && exit 1 || true ;\
done
.PHONY: checkdoc
checkdoc: ## Check docstring style
@for file in $(for_checkdoc); do \
echo "[checkdoc] $$file" ;\
$(EMACS) -Q --batch \
--eval "(or (fboundp 'checkdoc-file) (kill-emacs))" \
--eval "(setq sentence-end-double-space nil)" \
--eval "(checkdoc-file \"$$file\")" 2>&1 \
| grep . && exit 1 || true ;\
done
.PHONY: longlines
longlines: ## Check for long lines
@scripts/check-line-length.bash
.PHONY: checkindent
checkindent: ## Ensure that indentation is correct
@tmpdir="$$(mktemp -d)"; for file in $(for_checkindent); do \
tmpfile="$$(basename $$file)"; \
echo "[checkindent] $$file"; \
$(EMACS) -Q --batch \
--eval "(setq inhibit-message t)" \
--eval "(load (expand-file-name \"indent.el\" ) nil t)" \
--eval "(load (expand-file-name \"straight.el\") nil t)" \
--eval "(load (expand-file-name \"tests/straight-test.el\") nil t)" \
--eval "(find-file \"$$file\")" \
--eval "(indent-region (point-min) (point-max))" \
--eval "(write-file \"$$tmpdir/$$tmpfile\")"; \
(diff <(cat "$$file" | nl -v1 -ba | \
sed "s/\t/: /" | sed "s/^ */$$tmpfile:/") \
<(cat "$$tmpdir/$$tmpfile" | nl -v1 -ba | \
sed "s/\t/: /" | sed "s/^ */$$tmpfile:/") ) \
| grep -F ">" | grep -o "[a-z].*" | grep . && exit 1 || true; \
done
.PHONY: toc
toc: README.md ## Update table of contents in README
@echo "[toc] $^"
@if command -v markdown-toc >/dev/null; then \
markdown-toc -i $^ ; \
else \
echo " --> markdown-toc missing, skipping" ; \
fi
.PHONY: clean
clean: ## Remove build artifacts
@echo "[clean]" *.elc
@rm -f *.elc
.PHONY: smoke
smoke: ## Run smoke test (for CI use only)
@scripts/smoke-test.bash
.PHONY: bench
bench: ## Run benchmarking script against package.el
@$(EMACS) -Q --batch -l benchmark/straight-bench.el \
-f straight-bench-batch
.PHONY: docker
docker: ## Start a Docker shell; e.g. make docker VERSION=25.3
@scripts/docker.bash "$(VERSION)" "$(CMD)"
.PHONY: test
test: straight.elc
$(EMACS) -Q --batch -L . -l ert -l ./tests/straight-test.el \
--eval "(let ((ert-quiet t)) \
(require 'straight-ert-print-hack) \
(ert-run-tests-batch-and-exit))"