forked from ankitects/anki
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
155 lines (119 loc) · 3.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
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
148
149
150
151
152
153
154
155
PREFIX := /usr
SHELL := bash
.SHELLFLAGS := -eu -o pipefail -c
.ONESHELL:
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
RUNARGS :=
.SUFFIXES:
$(shell mkdir -p .build)
# Installing
######################
.PHONY: all install uninstall
all:
@echo "You can run Anki from this folder with 'make run'."
@echo
@echo "After confirming it's working, to install Anki system-wide, use"
@echo "'make build && sudo make install'."
@echo
@echo "To undo a system install, use 'sudo make uninstall'."
install:
rm -rf ${DESTDIR}${PREFIX}/share/anki
mkdir -p ${DESTDIR}${PREFIX}/share/anki
cp -av anki aqt web ${DESTDIR}${PREFIX}/share/anki/
-cp -av locale ${DESTDIR}${PREFIX}/share/anki/
sed -e 's:@PREFIX@:${PREFIX}:' tools/runanki.system.in > tools/runanki.system
install -m 0755 -D tools/runanki.system ${DESTDIR}${PREFIX}/bin/anki
install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/pixmaps anki.xpm anki.png
install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/applications anki.desktop
install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/man/man1 anki.1
install -m 0644 -D -t ${DESTDIR}${PREFIX}/share/doc/anki README.contributing README.development README.md LICENSE LICENSE.logo
-xdg-mime install anki.xml --novendor
-xdg-mime default anki.desktop application/x-anki
-xdg-mime default anki.desktop application/x-apkg
@echo
@echo "Install complete."
uninstall:
rm -rf ${DESTDIR}${PREFIX}/share/anki
rm -rf ${DESTDIR}${PREFIX}/bin/anki
rm -rf ${DESTDIR}${PREFIX}/share/pixmaps/anki.xpm
rm -rf ${DESTDIR}${PREFIX}/share/pixmaps/anki.png
rm -rf ${DESTDIR}${PREFIX}/share/applications/anki.desktop
rm -rf ${DESTDIR}${PREFIX}/share/man/man1/anki.1
-xdg-mime uninstall ${DESTDIR}${PREFIX}/share/mime/packages/anki.xml
@echo
@echo "Uninstall complete."
# Prerequisites
######################
REQS := .build/pyrunreqs .build/pydevreqs .build/jsreqs
.build/pyrunreqs: requirements.txt
pip install -r $<
./tools/typecheck-setup.sh
touch $@
.build/pydevreqs: requirements.dev
pip install -r $<
touch $@
.build/jsreqs: ts/package.json
(cd ts && npm i)
touch $@
# Typescript source
######################
TSDEPS := $(wildcard ts/src/*.ts)
JSDEPS := $(patsubst ts/src/%.ts, web/%.js, $(TSDEPS))
# Building
######################
BUILDDEPS := .build/ui .build/js
.build/ui: $(REQS) $(shell find designer -type f)
./tools/build_ui.sh
touch $@
.build/js: $(REQS) $(TSDEPS)
(cd ts && npm run build)
touch $@
.PHONY: build clean
build: $(BUILDDEPS)
.PHONY: clean
clean:
rm -rf .build
rm -rf $(JSDEPS)
# Running
######################
.PHONY: run
run: build
./runanki ${RUNARGS}
# Checking
######################
.PHONY: check
check: mypy pytest pylint pytype checkpretty
# Checking python
######################
PYCHECKDEPS := $(BUILDDEPS) $(shell find anki aqt -name '*.py' | grep -v buildhash.py)
.build/mypy: $(PYCHECKDEPS)
mypy anki aqt
touch $@
.build/pytest: $(PYCHECKDEPS)
./tools/tests.sh
touch $@
.build/pylint: $(PYCHECKDEPS)
pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=PyQt5 anki aqt
touch $@
.build/pytype: $(PYCHECKDEPS)
pytype --config pytype.conf
touch $@
.PHONY: mypy pytest pylint pytype
mypy: .build/mypy
pytest: .build/pytest
pylint: .build/pylint
pytype: .build/pytype
# Checking typescript
######################
TSCHECKDEPS := $(BUILDDEPS) $(TSDEPS)
.build/checkpretty: $(TSCHECKDEPS)
(cd ts && npm run check-pretty)
touch $@
.build/pretty: $(TSCHECKDEPS)
(cd ts && npm run pretty)
touch $@
.PHONY: pretty checkpretty
pretty: .build/pretty
checkpretty: .build/checkpretty