mirror of
https://github.com/ankitects/anki.git
synced 2025-11-13 08:07:11 -05:00
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.
This commit is contained in:
parent
95404ed2d7
commit
19f1c98025
14 changed files with 109 additions and 42 deletions
55
Makefile
55
Makefile
|
|
@ -1,4 +1,12 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
ECHOCMD := /bin/echo -e
|
||||||
|
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
IS_WINDOWS := true
|
||||||
|
else
|
||||||
|
IS_WINDOWS :=
|
||||||
|
endif
|
||||||
|
|
||||||
.SHELLFLAGS := -eu -o pipefail -c
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
.DELETE_ON_ERROR:
|
.DELETE_ON_ERROR:
|
||||||
MAKEFLAGS += --warn-undefined-variables
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
|
@ -18,10 +26,11 @@ all: run
|
||||||
# - modern pip required for wheel
|
# - modern pip required for wheel
|
||||||
# - add qt if missing
|
# - add qt if missing
|
||||||
pyenv:
|
pyenv:
|
||||||
python3 -m venv pyenv && \
|
python$(if ${IS_WINDOWS},,3) -m venv pyenv && \
|
||||||
. pyenv/bin/activate && \
|
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
|
||||||
pip install --upgrade pip setuptools && \
|
python --version && \
|
||||||
python -c 'import PyQt5' 2>/dev/null || pip install -r qt/requirements.qt
|
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
|
# update build hash
|
||||||
.PHONY: buildhash
|
.PHONY: buildhash
|
||||||
|
|
@ -34,42 +43,42 @@ buildhash:
|
||||||
|
|
||||||
.PHONY: develop
|
.PHONY: develop
|
||||||
develop: pyenv buildhash
|
develop: pyenv buildhash
|
||||||
@set -e && \
|
set -e && \
|
||||||
. pyenv/bin/activate && \
|
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
|
||||||
for dir in $(DEVEL); do \
|
for dir in $(DEVEL); do \
|
||||||
$(SUBMAKE) -C $$dir develop BUILDFLAGS="$(BUILDFLAGS)"; \
|
$(SUBMAKE) -C $$dir develop BUILDFLAGS="$(BUILDFLAGS)"; \
|
||||||
done
|
done
|
||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: develop
|
run: develop
|
||||||
@set -e && \
|
set -e && \
|
||||||
. pyenv/bin/activate && \
|
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
|
||||||
echo "Starting Anki..."; \
|
echo "Starting Anki..."; \
|
||||||
qt/runanki $(RUNFLAGS)
|
python qt/runanki $(RUNFLAGS)
|
||||||
|
|
||||||
.PHONY: build
|
.PHONY: build
|
||||||
build: clean-dist build-rspy build-pylib build-qt add-buildhash
|
build: clean-dist build-rspy build-pylib build-qt add-buildhash
|
||||||
@echo
|
echo
|
||||||
@echo "Build complete."
|
echo "Build complete."
|
||||||
|
|
||||||
.PHONY: build-rspy
|
.PHONY: build-rspy
|
||||||
build-rspy: pyenv buildhash
|
build-rspy: pyenv buildhash
|
||||||
@. pyenv/bin/activate && \
|
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
|
||||||
$(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)"
|
$(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)"
|
||||||
|
|
||||||
.PHONY: build-pylib
|
.PHONY: build-pylib
|
||||||
build-pylib:
|
build-pylib:
|
||||||
@. pyenv/bin/activate && \
|
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
|
||||||
$(SUBMAKE) -C pylib build
|
$(SUBMAKE) -C pylib build
|
||||||
|
|
||||||
.PHONY: build-qt
|
.PHONY: build-qt
|
||||||
build-qt:
|
build-qt:
|
||||||
@. pyenv/bin/activate && \
|
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
|
||||||
$(SUBMAKE) -C qt build
|
$(SUBMAKE) -C qt build
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
clean: clean-dist
|
clean: clean-dist
|
||||||
@set -e && \
|
set -e && \
|
||||||
for dir in $(DEVEL); do \
|
for dir in $(DEVEL); do \
|
||||||
$(SUBMAKE) -C $$dir clean; \
|
$(SUBMAKE) -C $$dir clean; \
|
||||||
done
|
done
|
||||||
|
|
@ -80,29 +89,29 @@ clean-dist:
|
||||||
|
|
||||||
.PHONY: check
|
.PHONY: check
|
||||||
check: pyenv buildhash
|
check: pyenv buildhash
|
||||||
@set -e && \
|
set -e && \
|
||||||
for dir in $(CHECKABLE_RS); do \
|
for dir in $(CHECKABLE_RS); do \
|
||||||
$(SUBMAKE) -C $$dir check; \
|
$(SUBMAKE) -C $$dir check; \
|
||||||
done; \
|
done; \
|
||||||
. pyenv/bin/activate && \
|
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
|
||||||
$(SUBMAKE) -C rspy develop && \
|
$(SUBMAKE) -C rspy develop && \
|
||||||
$(SUBMAKE) -C pylib develop && \
|
$(SUBMAKE) -C pylib develop && \
|
||||||
for dir in $(CHECKABLE_PY); do \
|
for dir in $(CHECKABLE_PY); do \
|
||||||
$(SUBMAKE) -C $$dir check; \
|
$(SUBMAKE) -C $$dir check; \
|
||||||
done;
|
done;
|
||||||
@echo
|
echo
|
||||||
@echo "All checks passed!"
|
echo "All checks passed!"
|
||||||
|
|
||||||
.PHONY: fix
|
.PHONY: fix
|
||||||
fix:
|
fix:
|
||||||
@set -e && \
|
set -e && \
|
||||||
. pyenv/bin/activate && \
|
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \
|
||||||
for dir in $(CHECKABLE_RS) $(CHECKABLE_PY); do \
|
for dir in $(CHECKABLE_RS) $(CHECKABLE_PY); do \
|
||||||
$(SUBMAKE) -C $$dir fix; \
|
$(SUBMAKE) -C $$dir fix; \
|
||||||
done; \
|
done; \
|
||||||
|
|
||||||
.PHONY: add-buildhash
|
.PHONY: add-buildhash
|
||||||
add-buildhash:
|
add-buildhash:
|
||||||
@ver=$$(cat meta/version); \
|
ver=$$(cat meta/version); \
|
||||||
hash=$$(cat meta/buildhash); \
|
hash=$$(cat meta/buildhash); \
|
||||||
rename "s/-$${ver}-/-$${ver}+$${hash}-/" dist/*-$$ver-*
|
rename "s/-$${ver}-/-$${ver}+$${hash}-/" dist/*-$$ver-*
|
||||||
|
|
|
||||||
|
|
@ -76,3 +76,25 @@ You can use homebrew to install some dependencies:
|
||||||
$ brew install python mpv lame portaudio protobuf npm rustup-init gettext rename
|
$ brew install python mpv lame portaudio protobuf npm rustup-init gettext rename
|
||||||
|
|
||||||
$ brew link gettext --force
|
$ brew link gettext --force
|
||||||
|
|
||||||
|
Windows users
|
||||||
|
----------
|
||||||
|
|
||||||
|
1. Download and install Cygwin and put its `/bin/` directory on your system path.
|
||||||
|
1. Install the Cygwin Packages: `apt-cyg install gettext rsync make`
|
||||||
|
1. Move these files to `/bin/`
|
||||||
|
1. /usr/bin/msgfmt.exe
|
||||||
|
1. /usr/bin/cyggettextsrc-0-19-8-1.dll
|
||||||
|
1. /usr/bin/cyggettextlib-0-19-8-1.dll
|
||||||
|
1. Download and install Python for Windows (not from Cygwin) and put `python.exe` (not `python3.exe`) on your system path.
|
||||||
|
1. Download and install pip for your Windows Python.
|
||||||
|
1. Download and install rust (compiler), npm, git and put them your system path.
|
||||||
|
1. Download and install Visual Studio 2017 or superior and:
|
||||||
|
1. `git clone https://github.com/evandroforks/portaudio`
|
||||||
|
1. Open the file `portaudio\build\msvc\portaudio.sln` with Visual Studio
|
||||||
|
1. Select the Solution Configuration as `Release` and the Solution Platforms as `x64` on the top toolbar
|
||||||
|
1. Go to the menu `Build -> Build Solution`
|
||||||
|
1. Copy the file `portaudio\build\msvc\x64\Release\portaudio.lib` to `C:\Python\libs\` (Or whatever your Windows Python is installed)
|
||||||
|
1. Open a `cmd.exe` (command prompt) on the anki repository and run the command `sh run`
|
||||||
|
1. Do not `bash run` because it my call for Windows Subsystem fo Linux
|
||||||
|
1. Do not use any Cygwin terminal as `mintty.exe` because the `rust lang` compiler does not work with them
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
ECHOCMD := /bin/echo -e
|
||||||
|
FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find
|
||||||
|
|
||||||
.SHELLFLAGS := -eu -o pipefail -c
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
.DELETE_ON_ERROR:
|
.DELETE_ON_ERROR:
|
||||||
MAKEFLAGS += --warn-undefined-variables
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
|
@ -14,11 +17,11 @@ PHONY: all
|
||||||
all: check
|
all: check
|
||||||
|
|
||||||
.build/run-deps: setup.py
|
.build/run-deps: setup.py
|
||||||
pip install -e .
|
python -m pip install -e .
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/dev-deps: requirements.dev
|
.build/dev-deps: requirements.dev
|
||||||
pip install -r requirements.dev
|
python -m pip install -r requirements.dev
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
PROTODEPS := $(wildcard ../proto/*.proto)
|
PROTODEPS := $(wildcard ../proto/*.proto)
|
||||||
|
|
@ -54,7 +57,7 @@ clean:
|
||||||
# Checking python
|
# Checking python
|
||||||
######################
|
######################
|
||||||
|
|
||||||
CHECKDEPS := $(shell find anki tests -name '*.py' | grep -v buildinfo.py)
|
CHECKDEPS := $(shell ${FIND_EXEC} anki tests -name '*.py' | grep -v buildinfo.py)
|
||||||
|
|
||||||
.build/mypy: $(CHECKDEPS)
|
.build/mypy: $(CHECKDEPS)
|
||||||
mypy anki
|
mypy anki
|
||||||
|
|
|
||||||
20
qt/Makefile
20
qt/Makefile
|
|
@ -1,4 +1,13 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
ECHOCMD := /bin/echo -e
|
||||||
|
FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find
|
||||||
|
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
IS_WINDOWS := true
|
||||||
|
else
|
||||||
|
IS_WINDOWS :=
|
||||||
|
endif
|
||||||
|
|
||||||
.SHELLFLAGS := -eu -o pipefail -c
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
.DELETE_ON_ERROR:
|
.DELETE_ON_ERROR:
|
||||||
MAKEFLAGS += --warn-undefined-variables
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
|
@ -14,14 +23,15 @@ PHONY: all
|
||||||
all: check
|
all: check
|
||||||
|
|
||||||
.build/run-deps: setup.py
|
.build/run-deps: setup.py
|
||||||
pip install -e .
|
$(if ${IS_WINDOWS},python -m pip install git+https://github.com/evandroforks/pyaudio,)
|
||||||
|
python -m pip install -e .
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/dev-deps: requirements.dev
|
.build/dev-deps: requirements.dev
|
||||||
pip install -r requirements.dev
|
python -m pip install -r requirements.dev
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
.build/ui: $(shell find designer -type f)
|
.build/ui: $(shell ${FIND_EXEC} designer -type f)
|
||||||
./tools/build_ui.sh
|
./tools/build_ui.sh
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
|
|
@ -73,7 +83,7 @@ JSDEPS := $(patsubst ts/src/%.ts, web/%.js, $(TSDEPS))
|
||||||
|
|
||||||
PYLIB := ../pylib
|
PYLIB := ../pylib
|
||||||
|
|
||||||
CHECKDEPS := $(shell find aqt tests -name '*.py' | grep -v buildinfo.py)
|
CHECKDEPS := $(shell ${FIND_EXEC} aqt tests -name '*.py' | grep -v buildinfo.py)
|
||||||
|
|
||||||
.build/mypy: $(CHECKDEPS) .build/qt-stubs
|
.build/mypy: $(CHECKDEPS) .build/qt-stubs
|
||||||
mypy aqt
|
mypy aqt
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,15 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
out=../aqt_data/locale/qt
|
out=../aqt_data/locale/qt
|
||||||
mkdir -p $out
|
mkdir -p "$out"
|
||||||
|
|
||||||
qtTranslations=$(python -c "from PyQt5.QtCore import *; print(QLibraryInfo.location(QLibraryInfo.TranslationsPath))")
|
qtTranslations="$(python -c "from PyQt5.QtCore import *; import sys; sys.stdout.write(QLibraryInfo.location(QLibraryInfo.TranslationsPath))")"
|
||||||
rsync -a $qtTranslations/qt* $out
|
unameOut="$(uname -s)"
|
||||||
|
|
||||||
|
case "${unameOut}" in
|
||||||
|
CYGWIN*)
|
||||||
|
qtTranslations="$(cygpath -u "${qtTranslations}")"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
rsync -a "$qtTranslations"/qt* "$out"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,5 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
# -*- coding: UTF-8 -*-
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "Anki desktop js support files",
|
"description": "Anki desktop js support files",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc --build; sass --no-source-map scss:../aqt_data/web",
|
"build": "tsc --build && sass --no-source-map scss:../aqt_data/web",
|
||||||
"pretty": "prettier --write src/*.ts",
|
"pretty": "prettier --write src/*.ts",
|
||||||
"check-pretty": "prettier --check src/*.ts"
|
"check-pretty": "prettier --check src/*.ts"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
ECHOCMD := /bin/echo -e
|
||||||
|
|
||||||
.SHELLFLAGS := -eu -o pipefail -c
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
.DELETE_ON_ERROR:
|
.DELETE_ON_ERROR:
|
||||||
MAKEFLAGS += --warn-undefined-variables
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
ECHOCMD := /bin/echo -e
|
||||||
|
|
||||||
.SHELLFLAGS := -eu -o pipefail -c
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
.DELETE_ON_ERROR:
|
.DELETE_ON_ERROR:
|
||||||
MAKEFLAGS += --warn-undefined-variables
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
ECHOCMD := /bin/echo -e
|
||||||
|
|
||||||
.SHELLFLAGS := -eu -o pipefail -c
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
.DELETE_ON_ERROR:
|
.DELETE_ON_ERROR:
|
||||||
MAKEFLAGS += --warn-undefined-variables
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
|
@ -44,7 +46,7 @@ clean:
|
||||||
RUST_TOOLCHAIN := $(shell cat rust-toolchain)
|
RUST_TOOLCHAIN := $(shell cat rust-toolchain)
|
||||||
|
|
||||||
.build/tools: requirements.txt rust-toolchain
|
.build/tools: requirements.txt rust-toolchain
|
||||||
pip install -r requirements.txt
|
python -m pip install -r requirements.txt
|
||||||
rustup toolchain install $(RUST_TOOLCHAIN)
|
rustup toolchain install $(RUST_TOOLCHAIN)
|
||||||
rustup component add rustfmt-preview --toolchain $(RUST_TOOLCHAIN)
|
rustup component add rustfmt-preview --toolchain $(RUST_TOOLCHAIN)
|
||||||
rustup component add clippy-preview --toolchain $(RUST_TOOLCHAIN)
|
rustup component add clippy-preview --toolchain $(RUST_TOOLCHAIN)
|
||||||
|
|
|
||||||
1
run
1
run
|
|
@ -1,3 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
python --version
|
||||||
make -C $(dirname $0) run RUNFLAGS="$*"
|
make -C $(dirname $0) run RUNFLAGS="$*"
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
ECHOCMD := /bin/echo -e
|
||||||
|
|
||||||
.SHELLFLAGS := -eu -o pipefail -c
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
.DELETE_ON_ERROR:
|
.DELETE_ON_ERROR:
|
||||||
MAKEFLAGS += --warn-undefined-variables
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
ECHOCMD := /bin/echo -e
|
||||||
|
|
||||||
.SHELLFLAGS := -eu -o pipefail -c
|
.SHELLFLAGS := -eu -o pipefail -c
|
||||||
.DELETE_ON_ERROR:
|
.DELETE_ON_ERROR:
|
||||||
MAKEFLAGS += --warn-undefined-variables
|
MAKEFLAGS += --warn-undefined-variables
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue