-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
53 lines (40 loc) · 1.33 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
SOURCES:=$(sort $(wildcard src/*.lua))
BACKENDS:=$(sort $(wildcard backends/*.lua))
EXTENSIONS:=$(sort $(wildcard extensions/*.lua))
OUTPUT:=plug.lua
TEMPDIR:=$(shell mktemp -d)
PLACEHOLDER=to be calculated at compile time
.PHONY: %.lua plug.lua src/00_header.lua src/99_footer.lua
$(SOURCES): %.lua
$(BACKENDS): %.lua
$(EXTENSIONS): %.lua
%.lua:
@echo
@cat $@
header:
@echo '------------------------------------------'
@echo '-- this file is automatically generated --'
@echo '-- do not edit directly --'
@echo '------------------------------------------'
@echo "local build_checksum = \"$(PLACEHOLDER)\""
@cat src/[email protected]
footer:
@echo
@cat src/[email protected]
preview: header $(SOURCES) $(BACKENDS) $(EXTENSIONS) footer
compile:
@$(MAKE) preview > $(TEMPDIR)/$(OUTPUT)
@CHECKSUM="$$(b2sum -l 256 $(TEMPDIR)/$(OUTPUT) | cut -d' ' -f1)" && \
sed "s/\"$(PLACEHOLDER)\"/\"$$CHECKSUM\"/g" $(TEMPDIR)/$(OUTPUT) > $(OUTPUT)
backend.%:
@sed 's/plug\.backend/plug.$@/g' $(TEMPDIR)/test.lua > $(TEMPDIR)/init.lua
tests/%:
@cat [email protected] > $(TEMPDIR)/test.lua
drytest-auto-%: tests/auto backend.% compile
@cat $(TEMPDIR)/init.lua
drytest-%: tests/init backend.% compile
@cat $(TEMPDIR)/init.lua
test-auto-%: tests/auto backend.% compile
nvim -u $(TEMPDIR)/init.lua
test-%: tests/init backend.% compile
nvim -u $(TEMPDIR)/init.lua