mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Merge pull request #459 from evandroforks/fix_windows_build
Fixed development compilation with Windows 10
This commit is contained in:
commit
aefce51dae
15 changed files with 101 additions and 35 deletions
|
@ -26,6 +26,7 @@ Arthur Milchior <arthur@milchior.fr>
|
||||||
Yngve Hoiseth <yngve@hoiseth.net>
|
Yngve Hoiseth <yngve@hoiseth.net>
|
||||||
Ijgnd
|
Ijgnd
|
||||||
Yoonchae Lee
|
Yoonchae Lee
|
||||||
|
Evandro Coan <github.com/evandrocoan>
|
||||||
Alan Du <alanhdu@gmail.com>
|
Alan Du <alanhdu@gmail.com>
|
||||||
|
|
||||||
********************
|
********************
|
||||||
|
|
41
Makefile
41
Makefile
|
@ -1,4 +1,17 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
PYTHON_BIN := python
|
||||||
|
ACTIVATE_SCRIPT := pyenv/Scripts/activate
|
||||||
|
else
|
||||||
|
PYTHON_BIN := python3
|
||||||
|
ACTIVATE_SCRIPT := pyenv/bin/activate
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef ANKI_EXTRA_PIP
|
||||||
|
ANKI_EXTRA_PIP := echo The custom pip command variable ANKI_EXTRA_PIP was not defined...
|
||||||
|
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 +31,12 @@ 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_BIN}" -m venv pyenv && \
|
||||||
. pyenv/bin/activate && \
|
. "${ACTIVATE_SCRIPT}" && \
|
||||||
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 && \
|
||||||
|
${ANKI_EXTRA_PIP} && \
|
||||||
|
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
|
||||||
|
@ -35,7 +50,7 @@ buildhash:
|
||||||
.PHONY: develop
|
.PHONY: develop
|
||||||
develop: pyenv buildhash prepare
|
develop: pyenv buildhash prepare
|
||||||
@set -eo pipefail && \
|
@set -eo pipefail && \
|
||||||
. pyenv/bin/activate && \
|
. "${ACTIVATE_SCRIPT}" && \
|
||||||
for dir in $(DEVEL); do \
|
for dir in $(DEVEL); do \
|
||||||
$(SUBMAKE) -C $$dir develop BUILDFLAGS="$(BUILDFLAGS)"; \
|
$(SUBMAKE) -C $$dir develop BUILDFLAGS="$(BUILDFLAGS)"; \
|
||||||
done
|
done
|
||||||
|
@ -43,9 +58,9 @@ develop: pyenv buildhash prepare
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: develop
|
run: develop
|
||||||
@set -eo pipefail && \
|
@set -eo pipefail && \
|
||||||
. pyenv/bin/activate && \
|
. "${ACTIVATE_SCRIPT}" && \
|
||||||
echo "Starting Anki..."; \
|
echo "Starting Anki..."; \
|
||||||
qt/runanki $(RUNFLAGS)
|
python qt/runanki $(RUNFLAGS)
|
||||||
|
|
||||||
.PHONY: prepare
|
.PHONY: prepare
|
||||||
prepare: rslib/ftl/repo qt/ftl/repo qt/po/repo
|
prepare: rslib/ftl/repo qt/ftl/repo qt/po/repo
|
||||||
|
@ -64,17 +79,17 @@ build: clean-dist build-rspy build-pylib build-qt add-buildhash
|
||||||
|
|
||||||
.PHONY: build-rspy
|
.PHONY: build-rspy
|
||||||
build-rspy: pyenv buildhash
|
build-rspy: pyenv buildhash
|
||||||
@. pyenv/bin/activate && \
|
@. "${ACTIVATE_SCRIPT}" && \
|
||||||
$(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 && \
|
@. "${ACTIVATE_SCRIPT}" && \
|
||||||
$(SUBMAKE) -C pylib build
|
$(SUBMAKE) -C pylib build
|
||||||
|
|
||||||
.PHONY: build-qt
|
.PHONY: build-qt
|
||||||
build-qt:
|
build-qt:
|
||||||
@. pyenv/bin/activate && \
|
@. "${ACTIVATE_SCRIPT}" && \
|
||||||
$(SUBMAKE) -C qt build
|
$(SUBMAKE) -C qt build
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
@ -94,7 +109,7 @@ check: pyenv buildhash
|
||||||
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 && \
|
. "${ACTIVATE_SCRIPT}" && \
|
||||||
$(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 \
|
||||||
|
@ -106,7 +121,7 @@ check: pyenv buildhash
|
||||||
.PHONY: fix
|
.PHONY: fix
|
||||||
fix:
|
fix:
|
||||||
@set -eo pipefail && \
|
@set -eo pipefail && \
|
||||||
. pyenv/bin/activate && \
|
. "${ACTIVATE_SCRIPT}" && \
|
||||||
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; \
|
||||||
|
|
|
@ -76,3 +76,29 @@ 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 (using Visual Studio)
|
||||||
|
----------
|
||||||
|
|
||||||
|
1. Download and install Cygwin and put its `/bin/` directory on your system path.
|
||||||
|
1. Install the Cygwin Packages: `apt-cyg install rsync make`
|
||||||
|
1. Download `gettext` 0.20.1 or superior and put its `bin` directory on your system path.
|
||||||
|
1. https://mlocati.github.io/articles/gettext-iconv-windows.html
|
||||||
|
1. If the Cygwin `/usr/bin/` directory exists, move all files from `/usr/bin/` to `/bin/`.
|
||||||
|
The problem with the `/usr/bin/` is that it should not exists. Cygwin should map/mount `/bin/`
|
||||||
|
into `/usr/bin/`, i.e., they should be the same directory.
|
||||||
|
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 (`python -m ensurepip`).
|
||||||
|
1. Download and install rust (compiler), npm, git and put them your system path.
|
||||||
|
1. Download and install the pyaudio wheel from: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pyaudio
|
||||||
|
1. After download the file for your Python version, you need to define the following environment
|
||||||
|
variable before running anki:
|
||||||
|
`set "ANKI_EXTRA_PIP=python -m pip install full/path/to/PyAudio‑0.2.11‑cp38‑cp38‑win_amd64.whl"`
|
||||||
|
1. If there is not an wheel available for your Python version, you can built it from the source
|
||||||
|
following the installation instructions on: https://github.com/evandroforks/pyaudio
|
||||||
|
After building and installing portaudio, you need to define the following environment
|
||||||
|
variable before running anki:
|
||||||
|
`set "ANKI_EXTRA_PIP=python -m pip install git+https://github.com/evandroforks/pyaudio"`
|
||||||
|
1. Open a `cmd.exe` (command prompt) on the anki repository and run the command `sh run`
|
||||||
|
1. Do not use `bash run` because it my call for Windows Subsystem for Linux
|
||||||
|
1. Do not use any Cygwin terminal as `mintty.exe` because the `rust lang` compiler does not work with them
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
FIND := $(if $(wildcard /bin/find),/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 +16,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 +56,7 @@ clean:
|
||||||
# Checking python
|
# Checking python
|
||||||
######################
|
######################
|
||||||
|
|
||||||
CHECKDEPS := $(shell find anki tests -name '*.py' | grep -v buildinfo.py)
|
CHECKDEPS := $(shell ${FIND} anki tests -name '*.py' | grep -v buildinfo.py)
|
||||||
|
|
||||||
.build/mypy: $(CHECKDEPS)
|
.build/mypy: $(CHECKDEPS)
|
||||||
mypy anki
|
mypy anki
|
||||||
|
|
12
qt/Makefile
12
qt/Makefile
|
@ -1,4 +1,6 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
FIND := $(if $(wildcard /bin/find),/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,14 +16,14 @@ 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 $@
|
||||||
|
|
||||||
.build/ui: $(shell find designer -type f)
|
.build/ui: $(shell ${FIND} designer -type f)
|
||||||
./tools/build_ui.sh
|
./tools/build_ui.sh
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
|
@ -75,7 +77,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} 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 -eo pipefail
|
set -eo pipefail
|
||||||
|
|
||||||
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,5 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
|
||||||
.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
|
||||||
|
FIND := $(if $(wildcard /bin/find),/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
|
||||||
|
@ -23,7 +25,7 @@ develop: .build/vernum ftl/repo
|
||||||
ftl/repo:
|
ftl/repo:
|
||||||
(cd ftl && ./scripts/fetch-latest-translations)
|
(cd ftl && ./scripts/fetch-latest-translations)
|
||||||
|
|
||||||
ALL_SOURCE := $(shell find src -type f) $(wildcard ftl/*.ftl)
|
ALL_SOURCE := $(shell ${FIND} src -type f) $(wildcard ftl/*.ftl)
|
||||||
|
|
||||||
# nightly currently required for ignoring files in rustfmt.toml
|
# nightly currently required for ignoring files in rustfmt.toml
|
||||||
RUST_TOOLCHAIN := $(shell cat rust-toolchain)
|
RUST_TOOLCHAIN := $(shell cat rust-toolchain)
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
FIND := $(if $(wildcard /bin/find),/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
|
||||||
|
@ -19,8 +21,8 @@ all: develop
|
||||||
develop: .build/develop
|
develop: .build/develop
|
||||||
|
|
||||||
DEPS := .build/tools .build/vernum ../meta/buildhash $(wildcard $(QT_FTLS)/*.ftl) \
|
DEPS := .build/tools .build/vernum ../meta/buildhash $(wildcard $(QT_FTLS)/*.ftl) \
|
||||||
$(shell find ../rslib/src -name '*.rs') $(wildcard ../proto/*) \
|
$(shell ${FIND} ../rslib/src -name '*.rs') $(wildcard ../proto/*) \
|
||||||
$(shell find ../rslib/ftl -type f)
|
$(shell ${FIND} ../rslib/ftl -type f)
|
||||||
|
|
||||||
.build/develop: $(DEPS)
|
.build/develop: $(DEPS)
|
||||||
touch ../proto/backend.proto
|
touch ../proto/backend.proto
|
||||||
|
@ -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,5 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
|
||||||
.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,5 @@
|
||||||
SHELL := bash
|
SHELL := /bin/bash
|
||||||
|
|
||||||
.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