anki/Makefile

166 lines
3.4 KiB
Makefile
Raw Normal View History

SHELL := /bin/bash
ifndef OS
OS := unknown
endif
ifeq (${OS},Windows_NT)
ifndef ACTIVATE_SCRIPT
ACTIVATE_SCRIPT := pyenv/Scripts/activate
endif
ifndef PYTHON_BIN
PYTHON_BIN := python
endif
else
ifndef ACTIVATE_SCRIPT
ACTIVATE_SCRIPT := pyenv/bin/activate
endif
ifndef PYTHON_BIN
PYTHON_BIN := python3
endif
endif
ifndef ANKI_EXTRA_PIP
ANKI_EXTRA_PIP := true
endif
2020-01-04 00:38:04 +01:00
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
SUBMAKE := $(MAKE) --print-directory
.SUFFIXES:
BUILDFLAGS := --release --strip
2020-03-06 04:29:23 +01:00
DEVFLAGS := $(BUILDFLAGS)
2020-01-04 00:38:04 +01:00
RUNFLAGS :=
2020-01-28 23:57:42 +01:00
CHECKABLE_PY := pylib qt
CHECKABLE_RS := rslib
2020-02-06 01:16:50 +01:00
DEVEL := rslib rspy pylib qt
2020-01-04 00:38:04 +01:00
2020-02-02 23:43:10 +01:00
.PHONY: all
all: run
2020-01-04 00:38:04 +01:00
# - modern pip required for wheel
# - add qt if missing
pyenv:
"${PYTHON_BIN}" -m venv pyenv && \
. "${ACTIVATE_SCRIPT}" && \
python --version && \
python -m pip install --upgrade pip setuptools && \
${ANKI_EXTRA_PIP} && \
python -c 'import PyQt5' 2>/dev/null || python -m pip install -r qt/requirements.qt
2020-01-04 00:38:04 +01:00
# update build hash
2020-01-05 01:28:48 +01:00
.PHONY: buildhash
buildhash:
@oldhash=$$(test -f meta/buildhash && cat meta/buildhash || true); \
2020-02-02 23:43:17 +01:00
newhash=$$(git rev-parse --short=8 HEAD || echo dev); \
2020-01-04 00:38:04 +01:00
if [ "$$oldhash" != "$$newhash" ]; then \
echo $$newhash > meta/buildhash; \
fi
.PHONY: develop
develop: pyenv buildhash prepare
@set -eo pipefail && \
. "${ACTIVATE_SCRIPT}" && \
2020-01-04 00:38:04 +01:00
for dir in $(DEVEL); do \
2020-03-06 00:33:53 +01:00
$(SUBMAKE) -C $$dir develop DEVFLAGS="$(DEVFLAGS)"; \
done
.PHONY: run
run: develop
@set -eo pipefail && \
. "${ACTIVATE_SCRIPT}" && \
2020-01-04 00:38:04 +01:00
echo "Starting Anki..."; \
python qt/runanki $(RUNFLAGS)
2020-01-04 00:38:04 +01:00
.PHONY: prepare
prepare: rslib/ftl/repo qt/ftl/repo qt/po/repo
2020-02-26 09:32:47 +01:00
rslib/ftl/repo:
$(MAKE) pull-i18n
2020-02-26 09:32:47 +01:00
qt/ftl/repo:
$(MAKE) pull-i18n
2020-02-26 09:32:47 +01:00
qt/po/repo:
$(MAKE) pull-i18n
2020-01-04 00:38:04 +01:00
.PHONY: build
build: clean-dist build-rspy build-pylib build-qt add-buildhash
@echo
@echo "Build complete."
2020-01-04 00:38:04 +01:00
.PHONY: build-rspy
2020-01-05 01:28:48 +01:00
build-rspy: pyenv buildhash
@. "${ACTIVATE_SCRIPT}" && \
$(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)"
.PHONY: build-pylib
build-pylib:
@. "${ACTIVATE_SCRIPT}" && \
$(SUBMAKE) -C pylib build
.PHONY: build-qt
build-qt:
@. "${ACTIVATE_SCRIPT}" && \
$(SUBMAKE) -C qt build
2020-01-04 00:38:04 +01:00
.PHONY: clean
clean: clean-dist
@set -eo pipefail && \
for dir in $(DEVEL); do \
2020-01-04 00:38:04 +01:00
$(SUBMAKE) -C $$dir clean; \
done
.PHONY: clean-dist
clean-dist:
rm -rf dist
2020-01-04 00:38:04 +01:00
.PHONY: check
check: pyenv buildhash prepare
@set -eo pipefail && \
.github/scripts/trailing-newlines.sh && \
2020-01-28 23:57:42 +01:00
for dir in $(CHECKABLE_RS); do \
$(SUBMAKE) -C $$dir check; \
done && \
. "${ACTIVATE_SCRIPT}" && \
2020-01-04 03:36:27 +01:00
$(SUBMAKE) -C rspy develop && \
$(SUBMAKE) -C pylib develop && \
2020-01-28 23:57:42 +01:00
for dir in $(CHECKABLE_PY); do \
2020-01-04 00:38:04 +01:00
$(SUBMAKE) -C $$dir check; \
done;
@echo
@echo "All checks passed!"
2020-01-04 00:38:04 +01:00
.PHONY: fix
fix:
@set -eo pipefail && \
. "${ACTIVATE_SCRIPT}" && \
2020-01-28 23:57:42 +01:00
for dir in $(CHECKABLE_RS) $(CHECKABLE_PY); do \
2020-01-04 00:38:04 +01:00
$(SUBMAKE) -C $$dir fix; \
done; \
.PHONY: add-buildhash
add-buildhash:
@ver=$$(cat meta/version); \
hash=$$(cat meta/buildhash); \
rename "s/-$${ver}-/-$${ver}+$${hash}-/" dist/*-$$ver-*
.PHONY: pull-i18n
pull-i18n:
(cd rslib/ftl && scripts/fetch-latest-translations)
(cd qt/ftl && scripts/fetch-latest-translations)
(cd qt/po && scripts/fetch-latest-translations)
.PHONY: push-i18n-ftl
push-i18n-ftl: pull-i18n
(cd rslib/ftl && scripts/upload-latest-templates)
(cd qt/ftl && scripts/upload-latest-templates)
.PHONY: push-i18n-po
push-i18n-po: pull-i18n
(cd qt/po && scripts/upload-latest-template)