-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
101 lines (90 loc) · 3.59 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
default: generate html
generate:
@rm -rf _gen && mkdir -p _gen && \
jsonnet -J . -m _gen -S main.jsonnet
html:
@./html/run.sh docs
generate: lessons/lesson1/examples.jsonnet
lessons/lesson1/examples.jsonnet:
@echo "Generating lessons/lesson1/examples.jsonnet..."
@cd lessons/lesson1 && \
echo "local example = (import 'coursonnet.libsonnet').example;" > \
examples.jsonnet && \
echo "[" >> examples.jsonnet && \
find . -type f -name \*.jsonnet | \
grep -v main.jsonnet | \
grep -v examples.jsonnet | \
sort | \
xargs --replace echo " example.new('{}'[2:], importstr '{}', import '{}')+example.withLink()," >> \
examples.jsonnet && \
echo "]" >> examples.jsonnet
generate: lessons/lesson5/examples.jsonnet
lessons/lesson5/examples.jsonnet:
@echo "Generating lessons/lesson5/examples.jsonnet..."
@cd lessons/lesson5 && \
echo "local example = (import 'coursonnet.libsonnet').example;" > \
examples.jsonnet && \
echo "[" >> examples.jsonnet && \
find ./example1 -type f -name example\*.jsonnet | \
sort | \
xargs --replace echo " example.new('{}'[2:], importstr '{}', import '{}')," >> \
examples.jsonnet && \
echo "]" >> examples.jsonnet
generate: lessons/lesson5/example1/docs/README.md
lessons/lesson5/example1/docs/README.md:
@cd lessons/lesson5/example1 && \
make docs
generate: lessons/lesson6/example1/example*.jsonnet.output
generate: lessons/lesson6/example1/pitfall*.jsonnet.output
lessons/lesson6/example1/%.jsonnet.output:
@echo "Generating lessons/lesson6/example1/$*.jsonnet.output..."
@cd lessons/lesson6/example1 && \
echo "# jsonnet -J lib -J vendor $*.jsonnet" > $*.jsonnet.output && \
jsonnet -J lib -J vendor $*.jsonnet 1>&2 &>> $*.jsonnet.output || true
generate: lessons/lesson6/example2/lib/webserver/make_test.output
lessons/lesson6/example2/lib/webserver/make_test.output:
@cd lessons/lesson6/example2/lib/webserver && \
echo "# make test" > make_test.output && \
make --no-print-directory test 1>&2 &>> make_test.output
generate: lessons/lesson6/examples.jsonnet
lessons/lesson6/examples.jsonnet:
@echo "Generating lessons/lesson6/examples.jsonnet..."
@cd lessons/lesson6 && \
echo "local example = (import 'coursonnet.libsonnet').example;" > \
examples.jsonnet && \
echo "[" >> examples.jsonnet && \
ls ./example1/*.jsonnet | grep '\(example\|pitfall\)*.jsonnet' | \
sort | \
xargs --replace echo " example.new('{}'[2:], importstr '{}', import '{}')," >> \
examples.jsonnet && \
ls ./example1/lib/webserver/*.libsonnet | \
sort | \
xargs --replace echo " example.new('{}'[2:], importstr '{}', import '{}')," >> \
examples.jsonnet && \
ls ./example1/base.json | \
sort | \
xargs --replace echo " example.new('{}'[2:], importstr '{}', import '{}')," >> \
examples.jsonnet && \
ls ./example1/*.jsonnet.output | grep '\(example\|pitfall\)*.jsonnet.output' | \
sort | \
xargs --replace echo " example.new('{}'[2:], importstr '{}', {filename:'{}'})," >> \
examples.jsonnet && \
find ./example2/lib/webserver -name 'vendor' -prune -o -type f -print | \
sort | \
xargs --replace echo " example.new('{}'[2:], importstr '{}', {filename:'{}'})," >> \
examples.jsonnet && \
echo "]" >> examples.jsonnet
test: lessons/lesson1/examples.jsonnet
@jsonnet -J . lessons/lesson1/examples.jsonnet > /dev/null && \
echo "Success!"
generate: lessons/lessons.jsonnet
lessons/lessons.jsonnet:
@echo "Generating lessons/lessons.jsonnet..."
@cd lessons && \
echo "[" > lessons.jsonnet && \
find ./*/ -type f -name main.jsonnet | \
sort | \
xargs --replace echo " (import '{}')," >> \
lessons.jsonnet && \
echo "]" >> lessons.jsonnet
.PHONY: generate html test