mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00
add rust checks, and clean up the makefile
This commit is contained in:
parent
249e2a2da0
commit
e893294ee4
1 changed files with 92 additions and 47 deletions
139
Makefile
139
Makefile
|
@ -41,6 +41,8 @@ install:
|
||||||
-xdg-mime default anki.desktop application/x-apkg
|
-xdg-mime default anki.desktop application/x-apkg
|
||||||
@echo
|
@echo
|
||||||
@echo "Install complete."
|
@echo "Install complete."
|
||||||
|
# fixme: _ankirs.so needs to be copied into system python env or
|
||||||
|
# 'maturin build' used
|
||||||
|
|
||||||
uninstall:
|
uninstall:
|
||||||
rm -rf ${DESTDIR}${PREFIX}/share/anki
|
rm -rf ${DESTDIR}${PREFIX}/share/anki
|
||||||
|
@ -56,24 +58,43 @@ uninstall:
|
||||||
# Prerequisites
|
# Prerequisites
|
||||||
######################
|
######################
|
||||||
|
|
||||||
RUNREQS := .build/pyrunreqs .build/jsreqs
|
RUNREQS := .build/py-run-deps .build/ts-deps
|
||||||
|
|
||||||
.build/pyrunreqs: requirements.txt
|
# Python prerequisites
|
||||||
|
######################
|
||||||
|
|
||||||
|
.build/py-run-deps: requirements.txt
|
||||||
pip install -r $<
|
pip install -r $<
|
||||||
touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/pycheckreqs: requirements.check .build/pyrunreqs
|
.build/py-check-reqs: requirements.check .build/py-run-deps
|
||||||
pip install -r $<
|
pip install -r $<
|
||||||
./tools/typecheck-setup.sh
|
./tools/typecheck-setup.sh
|
||||||
touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/rustreqs: .build/pyrunreqs
|
# TS prerequisites
|
||||||
pip install maturin
|
######################
|
||||||
touch $@
|
|
||||||
|
|
||||||
.build/jsreqs: ts/package.json
|
.build/ts-deps: ts/package.json
|
||||||
(cd ts && npm i)
|
(cd ts && npm i)
|
||||||
touch $@
|
@touch $@
|
||||||
|
|
||||||
|
# Rust prerequisites
|
||||||
|
######################
|
||||||
|
|
||||||
|
.build/rust-deps: .build/py-run-deps
|
||||||
|
pip install maturin
|
||||||
|
@touch $@
|
||||||
|
|
||||||
|
RUST_TOOLCHAIN := $(shell cat rs/rust-toolchain)
|
||||||
|
|
||||||
|
.build/rs-fmt-deps:
|
||||||
|
rustup component add rustfmt-preview --toolchain $(RUST_TOOLCHAIN)
|
||||||
|
@touch $@
|
||||||
|
|
||||||
|
.build/rs-clippy-deps:
|
||||||
|
rustup component add clippy-preview --toolchain $(RUST_TOOLCHAIN)
|
||||||
|
@touch $@
|
||||||
|
|
||||||
# Typescript source
|
# Typescript source
|
||||||
######################
|
######################
|
||||||
|
@ -84,7 +105,7 @@ JSDEPS := $(patsubst ts/src/%.ts, web/%.js, $(TSDEPS))
|
||||||
# Rust source
|
# Rust source
|
||||||
######################
|
######################
|
||||||
|
|
||||||
RSDEPS := $(wildcard rs/src/*.rs)
|
RSDEPS := $(wildcard rs/*/src/*.rs)
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
######################
|
######################
|
||||||
|
@ -93,15 +114,15 @@ BUILDDEPS := .build/ui .build/js .build/rs
|
||||||
|
|
||||||
.build/ui: $(RUNREQS) $(shell find designer -type f)
|
.build/ui: $(RUNREQS) $(shell find designer -type f)
|
||||||
./tools/build_ui.sh
|
./tools/build_ui.sh
|
||||||
touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/js: .build/jsreqs $(TSDEPS)
|
.build/js: .build/ts-deps $(TSDEPS)
|
||||||
(cd ts && npm run build)
|
(cd ts && npm run build)
|
||||||
touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/rs: .build/rustreqs $(RUNREQS) $(RSDEPS)
|
.build/rs: .build/rust-deps $(RUNREQS) $(RSDEPS)
|
||||||
(cd rs && maturin develop $(RUSTARGS))
|
(cd rs/pybridge && maturin develop $(RUSTARGS))
|
||||||
touch $@
|
@touch $@
|
||||||
|
|
||||||
.PHONY: build clean
|
.PHONY: build clean
|
||||||
|
|
||||||
|
@ -124,61 +145,85 @@ run: build
|
||||||
######################
|
######################
|
||||||
|
|
||||||
.PHONY: check
|
.PHONY: check
|
||||||
check: mypy pyimports pyfmt pytest pylint checkpretty
|
check: rs-test rs-fmt rs-clippy py-mypy py-test py-fmt py-imports py-lint ts-fmt
|
||||||
|
|
||||||
# Checking python
|
# Checking python
|
||||||
######################
|
######################
|
||||||
|
|
||||||
PYCHECKDEPS := $(BUILDDEPS) .build/pycheckreqs $(shell find anki aqt -name '*.py' | grep -v buildhash.py)
|
PYCHECKDEPS := $(BUILDDEPS) .build/py-check-reqs $(shell find anki aqt -name '*.py' | grep -v buildhash.py)
|
||||||
|
|
||||||
.build/mypy: $(PYCHECKDEPS)
|
.build/py-mypy: $(PYCHECKDEPS)
|
||||||
mypy anki aqt
|
mypy anki aqt
|
||||||
touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/pytest: $(PYCHECKDEPS) $(wildcard tests/*.py)
|
.build/pytest: $(PYCHECKDEPS) $(wildcard tests/*.py)
|
||||||
./tools/tests.sh
|
./tools/tests.sh
|
||||||
touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/pylint: $(PYCHECKDEPS)
|
.build/py-lint: $(PYCHECKDEPS)
|
||||||
pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=PyQt5,_ankirs anki aqt
|
pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=PyQt5,_ankirs anki aqt
|
||||||
touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/pyimports: $(PYCHECKDEPS)
|
.build/py-imports: $(PYCHECKDEPS)
|
||||||
isort anki aqt --check # if this fails, run 'make fixpyimports'
|
isort anki aqt --check # if this fails, run 'make fix-py-imports'
|
||||||
touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/pyfmt: $(PYCHECKDEPS)
|
.build/py-fmt: $(PYCHECKDEPS)
|
||||||
black --check $(BLACKARGS) # if this fails, run 'make fixpyfmt'
|
black --check $(BLACKARGS) # if this fails, run 'make fix-py-fmt'
|
||||||
touch $@
|
@touch $@
|
||||||
|
|
||||||
.PHONY: mypy pytest pylint pyimports pyfmt
|
.PHONY: py-mypy py-test py-lint py-imports py-fmt
|
||||||
mypy: .build/mypy
|
py-mypy: .build/py-mypy
|
||||||
pytest: .build/pytest
|
py-test: .build/py-test
|
||||||
pylint: .build/pylint
|
py-lint: .build/py-lint
|
||||||
pyimports: .build/pyimports
|
py-imports: .build/py-imports
|
||||||
pyfmt: .build/pyfmt
|
py-fmt: .build/py-fmt
|
||||||
|
|
||||||
.PHONY: fixpyimports fixpyfmt
|
.PHONY: fix-py-imports fix-py-fmt
|
||||||
|
|
||||||
fixpyimports:
|
fix-py-imports:
|
||||||
isort anki aqt
|
isort anki aqt
|
||||||
|
|
||||||
fixpyfmt:
|
fix-py-fmt:
|
||||||
black $(BLACKARGS) anki aqt
|
black $(BLACKARGS) anki aqt
|
||||||
|
|
||||||
|
# Checking rust
|
||||||
|
######################
|
||||||
|
|
||||||
|
.build/rs-test: $(RSDEPS)
|
||||||
|
(cd rs/ankirs && cargo test)
|
||||||
|
@touch $@
|
||||||
|
|
||||||
|
.build/rs-fmt: .build/rs-fmt-deps $(RSDEPS)
|
||||||
|
(cd rs && cargo fmt -- --check) # if this fails, run 'make fix-rs-fmt'
|
||||||
|
@touch $@
|
||||||
|
|
||||||
|
.build/rs-clippy: .build/rs-clippy-deps $(RSDEPS)
|
||||||
|
(cd rs && cargo clippy -- -D warnings)
|
||||||
|
@touch $@
|
||||||
|
|
||||||
|
.PHONY: rs-test rs-fmt fix-rs-fmt rs-clippy
|
||||||
|
|
||||||
|
rs-test: .build/rs-test
|
||||||
|
rs-fmt: .build/rs-fmt
|
||||||
|
rs-clippy: .build/rs-clippy
|
||||||
|
|
||||||
|
fix-rs-fmt:
|
||||||
|
(cd rs && cargo fmt)
|
||||||
|
|
||||||
|
|
||||||
# Checking typescript
|
# Checking typescript
|
||||||
######################
|
######################
|
||||||
|
|
||||||
TSCHECKDEPS := $(BUILDDEPS) $(TSDEPS)
|
TSCHECKDEPS := $(BUILDDEPS) $(TSDEPS)
|
||||||
|
|
||||||
.build/checkpretty: $(TSCHECKDEPS)
|
.build/ts-fmt: $(TSCHECKDEPS)
|
||||||
(cd ts && npm run check-pretty) # if this fails, run 'make pretty'
|
(cd ts && npm run check-pretty) # if this fails, run 'make fix-ts-fmt'
|
||||||
touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/pretty: $(TSCHECKDEPS)
|
.PHONY: fix-ts-fmt ts-fmt
|
||||||
|
ts-fmt: .build/ts-fmt
|
||||||
|
|
||||||
|
fix-ts-fmt:
|
||||||
(cd ts && npm run pretty)
|
(cd ts && npm run pretty)
|
||||||
touch $@
|
|
||||||
|
|
||||||
.PHONY: pretty checkpretty
|
|
||||||
pretty: .build/pretty
|
|
||||||
checkpretty: .build/checkpretty
|
|
||||||
|
|
Loading…
Reference in a new issue