forked from ad-si/invoice-maker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
75 lines (57 loc) · 1.53 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
.PHONY: help
help: makefile
@tail -n +4 makefile | grep ".PHONY"
.PHONY: unit-tests
unit-tests:
typst compile tests.typ
examples/%.check: examples/%.typ
@typst compile --root="." $<
@printf \
"Compare '%s.pdf' to expected output '%s' " \
"$(basename $<)" \
"fixtures/expected-$*.pdf"
@magick \
-density 150 \
"$(basename $<).pdf" \
null: "fixtures/expected-$*.pdf" \
-compose difference \
-layers composite \
"diff_$*_%d.png"
@identify -format "%@" "diff_$*_0.png" \
2>&1 | grep -q 'not contain' \
&& (echo "✅"; exit 0) \
|| (echo "❌: examples/$*.pdf changed -> diff_$*_0.png"; exit 1)
template/main.pdf: template/main-local.typ invoice-maker.typ
typst compile --root='.' $< $@
.INTERMEDIATE: template/main-local.typ
template/main-local.typ: template/main.typ
echo '#import "../invoice-maker.typ": *' > $@
tail -n +2 $< >> $@
.PHONY: test
test: \
unit-tests \
examples/minimal-data.check \
examples/en.check \
examples/de.check \
examples/with-body.check \
examples/discount-fixed.typ \
examples/discount-proportionate.typ \
examples/load-yaml.check \
examples/custom-language.check \
template/main.pdf
examples/en.pdf: examples/en.typ
typst compile $<
images/example-invoice.png: examples/en.pdf
convert \
-density 300 \
-resize 640 \
$< \
-flatten \
\( +clone -background black -shadow 30x25+0+0 \) \
+swap -background white -layers merge +repage \
$@
images/example-invoice-hq.png: examples/en.pdf
convert -density 250 -flatten $< $@
clean:
rm -f diff_*.png
rm -f examples/*.pdf