-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
93 lines (69 loc) · 2.13 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
.PHONY: docs deps
# Working directory variable
wd := $(shell git rev-parse --show-toplevel)
# Monitor file changes at filepath $(1) and evaluate expression $(2) on events
define monitor-file-changes
fswatch -rv $(1) | xargs -I {} sh -c '$(call $(2))'
endef
# Build the Ki spoon
define build-command
$(wd)/build.sh
endef
# Run lua linter on src and spec files
define lint-command
luacheck src/*.lua spec/*.lua
endef
# Run busted unit tests and write coverage report with optional tag argument
define test-command
busted -c -t "$(tag)"; luacov-console; luacov-console -s;
endef
# Generate html and markup docs and copy styles to output directory
define generate-docs-command
$(wd)/docs/build_docs.py -i "Ki" \
--output_dir $(wd)/docs \
--templates $(wd)/docs/templates/ \
--html --markdown --standalone --validate . && \
cp $(wd)/docs/templates/docs.css $(wd)/docs/html/docs.css
endef
spoon:
$(call build-command)
cp -r $(wd)/dist/build $(wd)/dist/Ki.spoon
zip -r dist/Ki.spoon.zip $(wd)/dist/Ki.spoon
dev:
$(call build-command)
watch-dev:
$(call monitor-file-changes,$(wd)/src,build-command)
lint:
$(call lint-command)
watch-lint:
$(call monitor-file-changes,$(wd)/src,lint-command)
test: clean-spoon clean-test
$(call test-command)
watch-test:
$(call monitor-file-changes,$(wd)/spec,test-command)
docs: clean-docs
$(call generate-docs-command)
watch-docs:
$(call monitor-file-changes,$(wd)/src,generate-docs-command)
deps:
luarocks install --lua-version 5.4 --tree deps fsm 1.1.0-1
luarocks install --lua-version 5.4 --tree deps lustache 1.3.1-0
luarocks install --lua-version 5.4 --tree deps middleclass 4.1.1-0
lint-deps:
luarocks install --lua-version 5.4 luacheck
docs-deps:
pip install --user jinja2 mistune pygments
test-deps:
luarocks install --lua-version 5.4 busted
luarocks install --lua-version 5.4 luacov
luarocks install --lua-version 5.4 luacov-console
dev-deps: lint-deps docs-deps test-deps
clean-spoon:
rm -rfv $(wd)/dist/build
rm -rfv $(wd)/dist/Ki.spoon
rm -fv $(wd)/dist/Ki.spoon.zip
clean-docs:
rm -rfv $(wd)/docs/markdown $(wd)/docs/html
clean-test:
rm -fv $(wd)/luacov.*
clean: clean-spoon clean-test