anki/Makefile
evandrocoan 19f1c98025 Fixed development compilation with Windows 10
1. Documented on README.development how to setup the environment
   for Windows.
2. Fixed qt/ts/package.json not working due usage of ; instead
   of &&
3. Fixed copy-qt-files rsync using Windows paths instead of Unix
   ones
4. Fixed Makefile's using Windows Linux Subsystem bash instead of
    the Cygwin one.
5. Ensured running the correct pip module by using python -m pip
    instead of just pip.
6. Fixed Makefiles using Windows `find` command, instead of the
    Cygwin's one (POSIX find).
7. Fixed pyenv sourcing/activate using /pyevn/bin/ instead of
    /python/Scripts/ on Windows.
8. Fixed pyaudio not installing/linking with portaudio on Windows
    by installing for a patched fork at evandroforks/pyaudio
9. Forked and fixed portaudio not building with Visual Studio 2017
    or superior and added the reference for the patched fork on
    README.development at evandroforks/portaudio.
2020-02-24 14:59:11 -03:00

118 lines
2.6 KiB
Makefile

SHELL := /bin/bash
ECHOCMD := /bin/echo -e
ifeq ($(OS),Windows_NT)
IS_WINDOWS := true
else
IS_WINDOWS :=
endif
.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_PY := pylib qt
CHECKABLE_RS := rslib
DEVEL := rslib rspy pylib qt
.PHONY: all
all: run
# - modern pip required for wheel
# - add qt if missing
pyenv:
python$(if ${IS_WINDOWS},,3) -m venv pyenv && \
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
python --version && \
python -m pip install --upgrade pip setuptools && \
python -c 'import PyQt5' 2>/dev/null || python -m pip install -r qt/requirements.qt
# update build hash
.PHONY: buildhash
buildhash:
oldhash=$$(test -f meta/buildhash && cat meta/buildhash || true); \
newhash=$$(git rev-parse --short=8 HEAD || echo dev); \
if [ "$$oldhash" != "$$newhash" ]; then \
echo $$newhash > meta/buildhash; \
fi
.PHONY: develop
develop: pyenv buildhash
set -e && \
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
for dir in $(DEVEL); do \
$(SUBMAKE) -C $$dir develop BUILDFLAGS="$(BUILDFLAGS)"; \
done
.PHONY: run
run: develop
set -e && \
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
echo "Starting Anki..."; \
python qt/runanki $(RUNFLAGS)
.PHONY: build
build: clean-dist build-rspy build-pylib build-qt add-buildhash
echo
echo "Build complete."
.PHONY: build-rspy
build-rspy: pyenv buildhash
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
$(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)"
.PHONY: build-pylib
build-pylib:
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
$(SUBMAKE) -C pylib build
.PHONY: build-qt
build-qt:
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
$(SUBMAKE) -C qt build
.PHONY: clean
clean: clean-dist
set -e && \
for dir in $(DEVEL); do \
$(SUBMAKE) -C $$dir clean; \
done
.PHONY: clean-dist
clean-dist:
rm -rf dist
.PHONY: check
check: pyenv buildhash
set -e && \
for dir in $(CHECKABLE_RS); do \
$(SUBMAKE) -C $$dir check; \
done; \
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
$(SUBMAKE) -C rspy develop && \
$(SUBMAKE) -C pylib develop && \
for dir in $(CHECKABLE_PY); do \
$(SUBMAKE) -C $$dir check; \
done;
echo
echo "All checks passed!"
.PHONY: fix
fix:
set -e && \
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
for dir in $(CHECKABLE_RS) $(CHECKABLE_PY); 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-*