2020-02-24 18:58:07 +01:00
|
|
|
SHELL := /bin/bash
|
|
|
|
|
|
|
|
ifeq ($(OS),Windows_NT)
|
2020-02-25 06:32:17 +01:00
|
|
|
PYTHON_BIN := python
|
|
|
|
ACTIVATE_SCRIPT := pyenv/Scripts/activate
|
2020-02-24 18:58:07 +01:00
|
|
|
else
|
2020-02-25 06:32:17 +01:00
|
|
|
PYTHON_BIN := python3
|
|
|
|
ACTIVATE_SCRIPT := pyenv/bin/activate
|
2020-02-24 18:58:07 +01:00
|
|
|
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
|
|
|
|
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:
|
2020-02-25 06:32:17 +01:00
|
|
|
"${PYTHON_BIN}" -m venv pyenv && \
|
|
|
|
. "${ACTIVATE_SCRIPT}" && \
|
2020-02-24 18:58:07 +01:00
|
|
|
python --version && \
|
|
|
|
python -m pip install --upgrade pip setuptools && \
|
|
|
|
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:
|
2020-01-04 00:38:04 +01:00
|
|
|
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
|
|
|
|
|
2020-01-08 21:44:46 +01:00
|
|
|
.PHONY: develop
|
|
|
|
develop: pyenv buildhash
|
2020-02-25 06:32:17 +01:00
|
|
|
set -eo pipefail && \
|
|
|
|
. "${ACTIVATE_SCRIPT}" && \
|
2020-01-04 00:38:04 +01:00
|
|
|
for dir in $(DEVEL); do \
|
2020-01-08 21:44:46 +01:00
|
|
|
$(SUBMAKE) -C $$dir develop BUILDFLAGS="$(BUILDFLAGS)"; \
|
|
|
|
done
|
|
|
|
|
|
|
|
.PHONY: run
|
|
|
|
run: develop
|
2020-02-25 06:32:17 +01:00
|
|
|
set -eo pipefail && \
|
|
|
|
. "${ACTIVATE_SCRIPT}" && \
|
2020-01-04 00:38:04 +01:00
|
|
|
echo "Starting Anki..."; \
|
2020-02-24 18:58:07 +01:00
|
|
|
python qt/runanki $(RUNFLAGS)
|
2020-01-04 00:38:04 +01:00
|
|
|
|
|
|
|
.PHONY: build
|
2020-01-04 01:02:43 +01:00
|
|
|
build: clean-dist build-rspy build-pylib build-qt add-buildhash
|
2020-02-25 06:32:17 +01:00
|
|
|
@echo
|
|
|
|
@echo "Build complete."
|
2020-01-04 00:38:04 +01:00
|
|
|
|
2020-01-04 01:02:43 +01:00
|
|
|
.PHONY: build-rspy
|
2020-01-05 01:28:48 +01:00
|
|
|
build-rspy: pyenv buildhash
|
2020-02-25 06:32:17 +01:00
|
|
|
. "${ACTIVATE_SCRIPT}" && \
|
2020-01-04 01:02:43 +01:00
|
|
|
$(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)"
|
|
|
|
|
|
|
|
.PHONY: build-pylib
|
|
|
|
build-pylib:
|
2020-02-25 06:32:17 +01:00
|
|
|
. "${ACTIVATE_SCRIPT}" && \
|
2020-01-04 01:02:43 +01:00
|
|
|
$(SUBMAKE) -C pylib build
|
|
|
|
|
|
|
|
.PHONY: build-qt
|
|
|
|
build-qt:
|
2020-02-25 06:32:17 +01:00
|
|
|
. "${ACTIVATE_SCRIPT}" && \
|
2020-01-04 01:02:43 +01:00
|
|
|
$(SUBMAKE) -C qt build
|
|
|
|
|
2020-01-04 00:38:04 +01:00
|
|
|
.PHONY: clean
|
2020-01-04 01:02:43 +01:00
|
|
|
clean: clean-dist
|
2020-02-25 07:16:57 +01:00
|
|
|
set -eo pipefail && \
|
2020-01-07 09:19:18 +01:00
|
|
|
for dir in $(DEVEL); do \
|
2020-01-04 00:38:04 +01:00
|
|
|
$(SUBMAKE) -C $$dir clean; \
|
|
|
|
done
|
|
|
|
|
2020-01-04 01:02:43 +01:00
|
|
|
.PHONY: clean-dist
|
|
|
|
clean-dist:
|
|
|
|
rm -rf dist
|
|
|
|
|
2020-01-04 00:38:04 +01:00
|
|
|
.PHONY: check
|
2020-01-05 01:28:48 +01:00
|
|
|
check: pyenv buildhash
|
2020-02-25 07:16:57 +01:00
|
|
|
set -eo pipefail && \
|
2020-01-28 23:57:42 +01:00
|
|
|
for dir in $(CHECKABLE_RS); do \
|
|
|
|
$(SUBMAKE) -C $$dir check; \
|
|
|
|
done; \
|
2020-02-25 06:32:17 +01:00
|
|
|
. "${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;
|
2020-02-25 06:32:17 +01:00
|
|
|
@echo
|
|
|
|
@echo "All checks passed!"
|
2020-01-04 00:38:04 +01:00
|
|
|
|
|
|
|
.PHONY: fix
|
|
|
|
fix:
|
2020-02-25 06:32:17 +01:00
|
|
|
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; \
|
2020-01-04 01:02:43 +01:00
|
|
|
|
|
|
|
.PHONY: add-buildhash
|
|
|
|
add-buildhash:
|
2020-02-24 18:58:07 +01:00
|
|
|
ver=$$(cat meta/version); \
|
2020-01-04 01:02:43 +01:00
|
|
|
hash=$$(cat meta/buildhash); \
|
2020-01-05 03:20:35 +01:00
|
|
|
rename "s/-$${ver}-/-$${ver}+$${hash}-/" dist/*-$$ver-*
|
2020-02-25 06:32:11 +01:00
|
|
|
|
|
|
|
|
|
|
|
.PHONY: pull-i18n
|
|
|
|
pull-i18n:
|
|
|
|
(cd rslib/ftl && scripts/fetch-latest-translations)
|
|
|
|
(cd qt/ftl && scripts/fetch-latest-translations)
|
|
|
|
(cd qt/i18n && ./pull-git)
|
|
|
|
|
|
|
|
.PHONY: push-i18n
|
|
|
|
push-i18n: pull-i18n
|
|
|
|
(cd rslib/ftl && scripts/upload-latest-templates)
|
|
|
|
(cd qt/ftl && scripts/upload-latest-templates)
|
|
|
|
(cd qt/i18n && ./sync-po-git)
|