-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
159 lines (112 loc) · 4.15 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
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
151
152
153
154
155
156
157
158
159
CASK ?= cask
EMACS ?= emacs
EMACS_BATCH = ${CASK} exec ${EMACS} -Q --batch -l package
REPO = github.com/iocanel/idee
DEPS_SCRIPT = assets/project-deps.el
DEPS_PNG = assets/project-deps.png
CASKDIR = .cask
SRCS = $(wildcard *.el)
TARGETS = $(SRCS:.el=.elc)
MAIN_PACKAGE_FILE = idee.el
ELISP_PACKAGE_FILE = idee-elisp.el
CLOJURE_PACKAGE_FILE = idee-clojure.el
GOLANG_PACKAGE_FILE = idee-golang.el
PYTHON_PACKAGE_FILE = idee-python.el
COUNSEL_PACKAGE_FILE = idee-counsel.el
VERSION := $(shell EMACS=${EMACS} ${CASK} version)
TAR := dist/idee/$(VERSION).tar
.PHONY: compile dist install help test clean clean-all release \
set-package-version assert-on-master assert-clean-worktree \
git-release github-browse-release
compile :
${CASK} install
dist : $(TAR)
$(TAR) : $(SRCS)
${CASK} package
help :
@echo 'Makefile for idee'
@echo
@echo 'Main tasks:'
@echo
@echo ' compile (default) Compile Lisp files.'
@echo ' help Show this usage information.'
@echo ' install Install idee using the Emacs package manager.'
@echo ' test Run automated test suites.'
@echo ' release Prepare for a GitHub release.'
@echo ' clean Delete generated output files.'
@echo ' clean-all Like clean, but also delete vendored local dependencies and the installed package.'
install : $(TAR)
$(EMACS_BATCH) \
--eval "(add-to-list 'package-archives '(\"MELPA Stable\" . \"https://stable.melpa.org/packages/\"))" \
-f package-initialize \
--eval "(unless package-archive-contents (package-refresh-contents))" \
--eval "(package-install-file \"$(TAR)\")"
test : $(SRCS)
${CASK} clean-elc
${CASK} exec ert-runner --verbose
clean :
${CASK} clean-elc
rm -rf dist
clean-all: clean
rm -rf $(CASKDIR) "~/.emacs.d/elpa/idee/$(VERSION)"
release : assert-clean-worktree assert-on-master clean test set-package-version dist git-release github-browse-release
@echo 'Release successful.'
assert-on-master :
@if [ "$$(git rev-parse --abbrev-ref HEAD)" != master ]; then \
echo "Attempting to deploy non-master branch to production."; exit 1; \
fi
assert-clean-worktree :
@if ! git diff-index --quiet HEAD -- ; then \
echo "Work tree is dirty. Aborting release."; exit 1; \
fi
set-package-version :
@read -p "Enter the next version (currently at $(VERSION)): " NEXT && \
if ! echo "$${NEXT}" | grep -Eq '[0-9]+\.[0-9]+\.[0-9]+'; then \
echo 'Must supply a semver tag, e.g. 1.2.3'; exit 1; \
fi && \
sed -i.bak "s/^;; Version:[^\n]*/;; Version: $${NEXT}/" "$(MAIN_PACKAGE_FILE)" && \
sed -i.bak "s/^;; Version:[^\n]*/;; Version: $${NEXT}/" "$(ELISP_PACKAGE_FILE)" && \
sed -i.bak "s/^;; Version:[^\n]*/;; Version: $${NEXT}/" "$(CLOJURE_PACKAGE_FILE)" && \
sed -i.bak "s/^;; Version:[^\n]*/;; Version: $${NEXT}/" "$(GOLANG_PACKAGE_FILE)" && \
sed -i.bak "s/^;; Version:[^\n]*/;; Version: $${NEXT}/" "$(PYTHON_PACKAGE_FILE)" && \
sed -i.bak "s/^;; Version:[^\n]*/;; Version: $${NEXT}/" "$(COUNSEL_PACKAGE_FILE)" && \
@rm "$(MAIN_PACKAGE_FILE).bak"
@rm "$(ELISP_PACKAGE_FILE).bak"
@rm "$(CLOJURE_PACKAGE_FILE).bak"
@rm "$(GOLANG_PACKAGE_FILE).bak"
@rm "$(PYTHON_PACKAGE_FILE).bak"
@rm "$(COUNSEL_PACKAGE_FILE).bak"
git-release :
@git add "$(MAIN_PACKAGE_FILE)"
@git add "$(ELISP_PACKAGE_FILE)"
@git add "$(CLOJURE_PACKAGE_FILE)"
@git add "$(GOLANG_PACKAGE_FILE)"
@git add "$(PYTHON_PACKAGE_FILE)"
@git add "$(COUNSEL_PACKAGE_FILE)"
@export TAG="$$(EMACS=${EMACS} ${CASK} version)"; \
git commit --quiet -m "Release $${TAG}" && \
git tag "$${TAG}" && \
while true; do \
read -p "Push to GitHub? [Yn]: " CHOICE; \
case $$CHOICE in \
[Yy]|"") git push --quiet origin master "$${TAG}"; break;; \
[Nn] ) echo "Remember to push the tag with your changes."; exit;; \
esac \
done
github-browse-release :
@export TAG="$$(git describe --abbrev=0 --tags)"; \
python -mwebbrowser "https://$(REPO)/releases/tag/$$TAG"
$(CASKDIR) :
${CASK} install
# Assert cask is installed
ifeq (, $(shell which cask))
define MESSAGE
Building this project requires Cask.
https://github.com/cask/cask
macOS:
brew install cask
*Nix:
curl -fsSL https://raw.githubusercontent.com/cask/cask/master/go | python
endef
$(error $(MESSAGE))
endif