-
Notifications
You must be signed in to change notification settings - Fork 44
/
Makefile
119 lines (85 loc) · 1.95 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
109
110
111
112
113
114
115
116
117
118
119
###
### Package
###
-include env.mk
NEEDED-PACKAGES ?= dash ag s
EL := wgrep.el
EL += wgrep-ack.el
EL += wgrep-ag.el
EL += wgrep-helm.el
EL += wgrep-pt.el
EL += wgrep-deadgrep.el
TEST_EL := wgrep-test.el
TEST_EL += wgrep-test-helper.el
##
## Emacs
##
EMACS ?= emacs
BATCH := $(EMACS) -Q -batch -L .
##
## package.el
##
ifdef ELPA-DIR
BATCH += -eval "(setq package-user-dir (expand-file-name \"$(ELPA-DIR)\"))"
endif
# This come from `package-lint/run-tests.sh`
define package-installer
"(progn \
(require 'package) \
(push '(\"melpa\" . \"https://melpa.org/packages/\") package-archives) \
(package-initialize) \
(package-refresh-contents) \
(dolist (pkg '($(1))) \
(unless (package-installed-p pkg) \
(package-install pkg))))"
endef
###
### Command
###
BUILD_BATCH := $(BATCH) -eval "(require 'package)" -f package-initialize
ifndef EMACS_LINT_IGNORE
BUILD_BATCH += -eval "(setq byte-compile-error-on-warn t)"
endif
ifdef EMACS_LINT_IGNORE
LINT_BATCH := true
else
LINT_BATCH := $(BATCH) -eval $(call package-installer, package-lint)
endif
CI_BATCH := $(BATCH) -eval $(call package-installer, package-lint $(NEEDED-PACKAGES))
###
### Files
###
ELC := $(EL:%.el=%.elc)
BUILD_GENERATED := *.elc
MAINTAINER_GENERATED := elpa *~
LOAD_EL := $(EL:%=-l %)
LOAD_ELC := $(ELC:%=-l %)
LOAD_TEST_EL := $(TEST_EL:%=-l %)
###
### General rule
###
.PHONY: all check compile clean
all: check
check: compile
$(BUILD_BATCH) $(LOAD_EL) $(LOAD_TEST_EL) -f ert-run-tests-batch-and-exit
$(BUILD_BATCH) $(LOAD_ELC) $(LOAD_TEST_EL) -f ert-run-tests-batch-and-exit
compile:
$(BUILD_BATCH) -f batch-byte-compile $(EL)
clean:
rm -rf $(BUILD_GENERATED)
###
### Maintainer rule
###
.PHONY: lint package maintainer-clean
lint:
$(LINT_BATCH) -f package-lint-batch-and-exit $(EL)
package: lint check
maintainer-clean: clean
rm -rf $(MAINTAINER_GENERATED)
###
### CI/CD rule
###
.PHONY: ci prepare-cicd
ci: prepare-cicd package
prepare-cicd:
$(CI_BATCH)