-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
95 lines (73 loc) · 2.81 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
.PHONY: all clean test log ls log minify
.PHONY: dev start start-dirmon start-daemon restart-daemon stop-daemon
PROJECT=cardgames
REDBEAN=${PROJECT}.com
REDBEAN_VERSION=2.0.17
VOICE=-v -v
REDBEAN_DL=https://redbean.dev/redbean-${REDBEAN_VERSION}.com
ZIP=zip.com
ZIP_DL=https://redbean.dev/zip.com
UNZIP=unzip.com
UNZIP_DL=https://redbean.dev/unzip.com
DEFINITIONS=definitions/redbean.lua
DEFINITIONS_DL=https://raw.githubusercontent.com/jart/cosmopolitan/d76dfadc7a0a9a5b7500d697e15a64c70d53eb12/tool/net/definitions.lua
NPD=--no-print-directory
all: add ${DEFINITIONS}
${REDBEAN}.template:
curl -s ${REDBEAN_DL} -o $@ -z $@ && \
chmod +x $@
${REDBEAN}: ${REDBEAN}.template
cp ${REDBEAN}.template ${REDBEAN}
${ZIP}:
curl -s ${ZIP_DL} -o $@ -z $@
chmod +x ${ZIP}
${DEFINITIONS}:
mkdir -p definitions
curl -Rso ${DEFINITIONS} ${DEFINITIONS_DL}
minify: ; @echo "TODO: https://github.com/coderaiser/minify"
bundle-js: bin/genmap js/libs/utils.js js/libs/dnd.js js/libs/mithril.js js/calculation.js
cd srv/js && ../../bin/genmap.sh libs/utils.js libs/dnd.js libs/mithril.js calculation.js
add: ${ZIP} ${REDBEAN}
cp -f ${REDBEAN}.template ${REDBEAN}
cd srv/ && ../${ZIP} -r ../${REDBEAN} `ls -A`
add-pack: ${ZIP} ${REDBEAN}
cp -f ${REDBEAN}.template ${REDBEAN}
cd pack/ && ../${ZIP} -r ../${REDBEAN} `ls -A`
unzip.com: ; curl -s ${ZIP_DL} -o $@ -z $@
ls: unzip.com
@unzip -vl ./${REDBEAN} | grep -v \
'usr/\|.symtab'
log: ${PROJECT}.log
@tail -f ${PROJECT}.log
start: ${REDBEAN}
./${REDBEAN} ${VOICE} $(ARGS)
start-daemon: ${REDBEAN}
@(test ! -f ${PROJECT}.pid && \
./${REDBEAN} ${VOICE} $(ARGS) -d -L ${PROJECT}.log -P ${PROJECT}.pid && \
printf "🦞 started $$(cat ${PROJECT}.pid)\n") \
|| echo "🦞 already running $$(cat ${PROJECT}.pid)"
start-dirmon: ; @$(MAKE) ${NPD} start-daemon ARGS="-D srv"
restart-daemon:
@(test ! -f ${PROJECT}.pid && \
./${REDBEAN} ${VOICE} $(ARGS) -d -L ${PROJECT}.log -P ${PROJECT} && \
printf "🦞 started $$(cat ${PROJECT}.pid)") \
|| kill -HUP $$(cat ${PROJECT}.pid) && \
printf "🦞 restarted $$(cat ${PROJECT}.pid)\n"
stop-daemon: ${PROJECT}.pid
@kill -TERM $$(cat ${PROJECT}.pid) && \
printf "🦞 stopped $$(cat ${PROJECT}.pid)\n" && \
rm ${PROJECT}.pid \
# This is a helpful target that packs up .lua/.init.lua and serves /srv with -D
dev:
@(test ! -f ${PROJECT}.pid && $(MAKE) ${NPD} add-pack && $(MAKE) ${NPD} start-dirmon) || \
($(MAKE) ${NPD} test && \
$(MAKE) ${NPD} stop-daemon && $(MAKE) ${NPD} add-pack && $(MAKE) ${NPD} start-dirmon)
@$(MAKE) ${NPD} log
test:
checkmake Makefile
lua test/calculation_test.lua
lua test/sql_test.lua
# TODO - possibly check if the pid is running before you rm the .pid
clean:
rm -f ${PROJECT}.log ${PROJECT}.pid ${REDBEAN} ${REDBEAN}.template ${ZIP} ${UNZIP} ${DEFINITIONS}
[ "$(ls -A definitions)" ] || rm -rf definitions