anki/Makefile

105 lines
2.1 KiB
Makefile
Raw Normal View History

2020-01-04 00:38:04 +01:00
SHELL := bash
.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 :=
CHECKABLE := rslib pylib qt
DEVEL := rspy pylib qt
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:
python3 -m venv pyenv && \
. pyenv/bin/activate && \
pip install --upgrade pip setuptools && \
python -c 'import PyQt5' 2>/dev/null || pip install -r qt/requirements.qt
# 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); \
newhash=$$(git rev-parse --short=8 HEAD); \
2020-01-04 00:38:04 +01:00
if [ "$$oldhash" != "$$newhash" ]; then \
echo $$newhash > meta/buildhash; \
fi
.PHONY: develop
develop: pyenv buildhash
@set -e && \
. pyenv/bin/activate && \
2020-01-04 00:38:04 +01:00
for dir in $(DEVEL); do \
$(SUBMAKE) -C $$dir develop BUILDFLAGS="$(BUILDFLAGS)"; \
done
.PHONY: run
run: develop
@set -e && \
. pyenv/bin/activate && \
2020-01-04 00:38:04 +01:00
echo "Starting Anki..."; \
qt/runanki $(RUNFLAGS)
.PHONY: build
build: clean-dist build-rspy build-pylib build-qt add-buildhash
2020-01-04 00:38:04 +01:00
@echo
@echo "Build complete."
.PHONY: build-rspy
2020-01-05 01:28:48 +01:00
build-rspy: pyenv buildhash
@. pyenv/bin/activate && \
$(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)"
.PHONY: build-pylib
build-pylib:
@. pyenv/bin/activate && \
$(SUBMAKE) -C pylib build
.PHONY: build-qt
build-qt:
@. pyenv/bin/activate && \
$(SUBMAKE) -C qt build
2020-01-04 00:38:04 +01:00
.PHONY: clean
clean: clean-dist
@set -e && \
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
2020-01-05 01:28:48 +01:00
check: pyenv buildhash
2020-01-06 04:15:20 +01:00
@set -e && \
. pyenv/bin/activate && \
2020-01-04 03:36:27 +01:00
$(SUBMAKE) -C rspy develop && \
$(SUBMAKE) -C pylib develop && \
2020-01-04 00:38:04 +01:00
for dir in $(CHECKABLE); do \
$(SUBMAKE) -C $$dir check; \
done;
@echo
@echo "All checks passed!"
.PHONY: fix
fix:
@set -e && \
2020-01-10 04:07:12 +01:00
. pyenv/bin/activate && \
2020-01-04 00:38:04 +01:00
for dir in $(CHECKABLE); do \
$(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-*