-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
147 lines (121 loc) · 4.38 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
SHELL := /bin/bash
PYTHON ?= python3
VERBOSE ?= --verbose
CSSV := https://jigsaw.w3.org/css-validator/validator
CSSOK := Congratulations! No Error Found.
HTMLV := https://html5.validator.nu
HTMLOK := The document is valid HTML5
URL := http://localhost:5000
H5VCMD := html5validator --show-warnings --log INFO --no-langdetect \
--ignore 'Unicode Normalization Form'
PYCOV := $(PYTHON) -mcoverage run --source jiten
export PYTHONWARNINGS := default
.PHONY: all test test-js ci-test coverage clean cleanup install
.PHONY: validate-css tmp-html check-html validate-html
.PHONY: validate-html-curl validate-html-py
all: ext
$(PYTHON) -m jiten.cli setup
test: all test-js
$(PYTHON) -m jiten.app $(VERBOSE) --doctest
$(PYTHON) -m jiten.cli $(VERBOSE) _doctest
$(PYTHON) -m jiten.freq $(VERBOSE) --doctest
$(PYTHON) -m jiten.jmdict $(VERBOSE) --doctest
$(PYTHON) -m jiten.kana $(VERBOSE) --doctest
$(PYTHON) -m jiten.kanji $(VERBOSE) --doctest
$(PYTHON) -m jiten.misc $(VERBOSE) --doctest
$(PYTHON) -m jiten.pitch $(VERBOSE) --doctest
$(PYTHON) -m jiten.sentences $(VERBOSE) --doctest
test-js:
node jiten/static/script.js
ci-test: test-js coverage validate-css validate-html check-html
coverage: tmp-html
$(PYCOV) -a -m jiten.app --doctest
$(PYCOV) -a -m jiten.cli _doctest
$(PYCOV) -a -m jiten.freq --doctest
$(PYCOV) -a -m jiten.jmdict --doctest
$(PYCOV) -a -m jiten.kana --doctest
$(PYCOV) -a -m jiten.kanji --doctest
$(PYCOV) -a -m jiten.misc --doctest
$(PYCOV) -a -m jiten.pitch --doctest
$(PYCOV) -a -m jiten.sentences --doctest
$(PYTHON) -mcoverage html
$(PYTHON) -mcoverage report
clean: cleanup
rm -f jiten/res/*.sqlite3
rm -f jiten/_sqlite3_pcre.*.so
rm -fr jiten.egg-info/
$(MAKE) -C jiten/res/jmdict clean
$(MAKE) -C jiten/res/sentences clean
cleanup:
find -name '*~' -delete -print
rm -fr jiten/__pycache__/ tmp-html/
rm -fr build/ dist/
rm -fr .coverage htmlcov/
rm -fr jiten/.version
$(MAKE) -C jiten/res/jmdict cleanup
install:
$(PYTHON) -mpip install -e .
validate-css:
curl -sF "file=@jiten/static/style.css;type=text/css" \
-- "$(CSSV)" | grep -qF '$(CSSOK)'
# TODO
tmp-html:
set -e; rm -fr tmp-html/; mkdir tmp-html; \
$(PYCOV) -m jiten.cli _serve tmp-html/.{running,done} & pid=$$!; \
dl() { f="$$1"; shift; curl -sG $(URL)"$$@" > tmp-html/"$$f".html; }; \
while [ ! -e tmp-html/.running ]; do sleep 1; done ; \
dl index ; \
dl cat /jmdict -d max=10 -d word=yes --data-urlencode query=cat ; \
dl absurd /jmdict -d max=10 -d word=yes --data-urlencode query=absurd ; \
dl neko /kanji -d max=10 -d word=yes --data-urlencode query=ねこ ; \
dl hi /kanji -d max=10 -d word=yes --data-urlencode query=日 ; \
dl kitten /sentences -d max=10 --data-urlencode query=kitten ; \
dl stroke /stroke ; \
dl j-b-f /jmdict/by-freq ; \
dl j-b-n1 /jmdict/by-jlpt/1 ; \
dl j-b-n2 /jmdict/by-jlpt/2 ; \
dl j-b-n3 /jmdict/by-jlpt/3 ; \
dl j-b-n4 /jmdict/by-jlpt/4 ; \
dl j-b-n5 /jmdict/by-jlpt/5 ; \
dl k-b-f /kanji/by-freq ; \
dl k-b-l /kanji/by-level ; \
dl k-b-j /kanji/by-jlpt ; \
dl k-b-s1 /kanji/by-skip/1 ; \
dl k-b-s2 /kanji/by-skip/2 ; \
dl k-b-s3 /kanji/by-skip/3 ; \
dl k-b-s4 /kanji/by-skip/4 ; \
touch tmp-html/.done ; wait $$pid
# TODO
check-html:
grep -qF 猫 tmp-html/cat.html
grep -qF "cat (esp. the domestic cat, Felis catus)" tmp-html/cat.html
grep -qF "word usually written using kana alone" tmp-html/cat.html
grep -qF 0x732b tmp-html/neko.html
grep -qF "counter for days" tmp-html/hi.html
validate-html: tmp-html validate-html-py
validate-html-curl:
for file in $$( find tmp-html/ -name '*.html' | sort ); do \
echo "validating $$file..."; \
curl -sF "file=@$$file;type=text/html" -- "$(HTMLV)" \
| grep -qF '$(HTMLOK)' || exit 1; \
done
validate-html-py:
unset JAVA_TOOL_OPTIONS && $(H5VCMD) --root tmp-html/
.PHONY: ext patch _version _package _publish
ext:
$(PYTHON) setup.py build_ext -i
patch:
$(MAKE) -C jiten/res/jmdict all
$(MAKE) -C jiten/res/jmdict cleanup
_version:
if [ -n "$$JITEN_VERSION" ]; then \
echo "v$$JITEN_VERSION"; \
else \
git describe --always; \
fi > jiten/.version
_package:
$(PYTHON) setup.py sdist bdist_wheel
twine check dist/*
_publish: cleanup _package
read -r -p "Are you sure? "; \
[[ "$$REPLY" == [Yy]* ]] && twine upload dist/*.tar.gz