anki/qt/Makefile

158 lines
3.6 KiB
Makefile
Raw Normal View History

SHELL := /bin/bash
ifndef SHELLFLAGS
SHELLFLAGS :=
endif
.SHELLFLAGS := -eu -o pipefail ${SHELLFLAGS} -c
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
MYPY_ARGS :=
PYLINT_ARGS :=
ifndef OS
OS := unknown
endif
# https://anki.tenderapp.com/discussions/beta-testing/1860-error-unused-type-ignore-comment
ifneq (${OS},Windows_NT)
MYPY_ARGS := --warn-unused-ignores
else
PYLINT_ARGS := --ignored-modules=win32file,pywintypes,socket,win32pipe
endif
.DELETE_ON_ERROR:
.SUFFIXES:
BLACKARGS := -t py36 aqt tests setup.py tools/*.py --exclude='aqt/forms|buildinfo|colors'
ISORTARGS := --profile black aqt tests setup.py
2020-01-03 05:32:26 +01:00
$(shell mkdir -p .build ../dist)
PHONY: all
all: check
.build/run-deps: setup.py
python -m pip install -e .
@touch $@
.build/dev-deps: requirements.dev
python -m pip install -r requirements.dev
@touch $@
.build/ui: $(shell "${FIND}" designer -type f)
./tools/build_ui.sh
@touch $@
.build/i18n: $(wildcard po/repo/desktop/*/anki.po)
(cd po && \
./scripts/build-mo-files && \
./scripts/copy-qt-files)
2020-01-02 23:24:59 +01:00
@touch $@
TSDEPS := $(wildcard ts/src/*.ts) $(wildcard ts/scss/*.scss) $(wildcard ../ts/src/scss/*)
.build/js: $(TSDEPS)
(cd ts && make build)
python ./tools/extract_scss_colors.py
@touch $@
.build/hooks: tools/genhooks_gui.py ../pylib/tools/hookslib.py
python tools/genhooks_gui.py
python -m black aqt/gui_hooks.py
2020-01-13 05:38:05 +01:00
@touch $@
BUILD_STEPS := .build/vernum .build/run-deps .build/dev-deps .build/js .build/ui aqt/buildinfo.py .build/hooks .build/i18n
# Checking
######################
.PHONY: check
2020-05-12 13:10:21 +02:00
check: .build/pyaudio $(BUILD_STEPS) .build/mypy .build/test .build/fmt .build/imports .build/lint .build/ts-fmt
# https://github.com/ankitects/anki/pull/611 - Automatically install pyaudio when running make check
2020-05-12 13:10:21 +02:00
.build/pyaudio:
python -m pip install pyaudio
2020-05-12 13:10:21 +02:00
@touch $@
.PHONY: fix
fix: $(BUILD_STEPS)
isort $(ISORTARGS)
python -m black $(BLACKARGS)
(cd ts && make fix)
.PHONY: clean
clean:
rm -rf .build aqt.egg-info build dist
# Checking Typescript
######################
JSDEPS := $(patsubst ts/src/%.ts, web/%.js, $(TSDEPS))
.build/ts-fmt: $(TSDEPS)
(cd ts && make check)
@touch $@
# Checking python
######################
PYLIB := ../pylib
CHECKDEPS := $(shell "${FIND}" aqt tests -name '*.py' | grep -v buildinfo.py)
.build/mypy: $(CHECKDEPS) .build/qt-stubs
python -m mypy ${MYPY_ARGS} aqt
@touch $@
.build/test: $(CHECKDEPS)
2020-01-08 06:52:51 +01:00
python -m pytest -s
@touch $@
.build/lint: $(CHECKDEPS)
python -m pylint -j 0 --rcfile=.pylintrc -f colorized ${PYLINT_ARGS} \
--extension-pkg-whitelist=PyQt5,ankirspy aqt tests setup.py
@touch $@
.build/imports: $(CHECKDEPS)
isort $(ISORTARGS) --check
@touch $@
.build/fmt: $(CHECKDEPS)
python -m black --check $(BLACKARGS)
@touch $@
.build/qt-stubs:
./tools/typecheck-setup.sh
@touch $@
# Building
######################
.PHONY: build
2020-04-07 02:56:41 +02:00
build: .build/build
2020-06-29 05:47:54 +02:00
.build/build: $(BUILD_STEPS) $(CHECKDEPS) $(wildcard ../ts/dist/*)
rm -rf dist build
2020-06-29 05:47:54 +02:00
rsync -a ../ts/dist/ aqt_data/web/
python setup.py -q bdist_wheel
rsync -a dist/*.whl ../dist/
2020-04-07 02:56:41 +02:00
touch $@
.PHONY: develop
2020-06-29 05:47:54 +02:00
develop: $(BUILD_STEPS) $(wildcard ../ts/dist/*)
rsync -a ../ts/dist/ aqt_data/web/
aqt/buildinfo.py: ../meta/version ../meta/buildhash
echo "buildhash='$$(cat ../meta/buildhash)'" > $@
echo "version='$$(cat ../meta/version)'" >> $@
VER := $(shell cat ../meta/version)
.build/vernum: ../meta/version
sed -i.bak 's/.*automatically updated 1.*/ "anki==$(VER)", # automatically updated 1/' setup.py
sed -i.bak 's/.*automatically updated 2.*/ version="$(VER)", # automatically updated 2/' setup.py
rm setup.py.bak
@touch $@