diff --git a/.gitignore b/.gitignore index 6b11f22da..1eed8291b 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ tools/runanki.system anki/buildhash.py .mypy_cache .pytype +.build diff --git a/Makefile b/Makefile index 2374ffc03..0c24d7d03 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,16 @@ -PREFIX=/usr +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) + +.PHONY: all install uninstall all: @echo "You can run Anki with ./runanki" @@ -32,3 +44,43 @@ uninstall: -xdg-mime uninstall ${DESTDIR}${PREFIX}/share/mime/packages/anki.xml @echo @echo "Uninstall complete." + +.PHONY: clean build run + +clean: + rm -rf .build + +build: .build/ui + +.build/ui: $(shell find designer -name '*.ui') + ./tools/build_ui.sh + touch $@ + +run: build + ./runanki ${RUNARGS} + +CHECKDEPS := .build/ui $(shell find anki aqt -name '*.py') + +.PHONY: check mypy test lint pytype + +check: mypy test lint pytype +mypy: .build/mypy +test: .build/test +lint: .build/lint +pytype: .build/pytype + +.build/mypy: $(CHECKDEPS) + mypy anki aqt + touch $@ + +.build/test: $(CHECKDEPS) + ./tools/tests.sh + touch $@ + +.build/lint: $(CHECKDEPS) + pylint -j 0 --rcfile=.pylintrc -f colorized --extension-pkg-whitelist=PyQt5 anki aqt + touch $@ + +.build/pytype: $(CHECKDEPS) + pytype --config pytype.conf + touch $@ diff --git a/tools/lint.sh b/tools/lint.sh deleted file mode 100755 index f50a652f0..000000000 --- a/tools/lint.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -set -e - -TOOLS="$(cd "`dirname "$0"`"; pwd)" -pylint -j 0 --rcfile=$TOOLS/../.pylintrc -f colorized --extension-pkg-whitelist=PyQt5 $TOOLS/../anki $TOOLS/../aqt diff --git a/tools/typecheck.sh b/tools/typecheck.sh deleted file mode 100755 index 1a61a6b06..000000000 --- a/tools/typecheck.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -e - -TOOLS="$(cd "`dirname "$0"`"; pwd)" -mypy $TOOLS/../anki $TOOLS/../aqt -(cd $TOOLS/.. && pytype --config pytype.conf)