diff --git a/Makefile b/Makefile index a2d8a7d44..e2273071f 100644 --- a/Makefile +++ b/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 .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables @@ -18,10 +26,11 @@ all: run # - 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 + 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 @@ -34,42 +43,42 @@ buildhash: .PHONY: develop develop: pyenv buildhash - @set -e && \ - . pyenv/bin/activate && \ + 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/bin/activate && \ + set -e && \ + . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ echo "Starting Anki..."; \ - qt/runanki $(RUNFLAGS) + python qt/runanki $(RUNFLAGS) .PHONY: build build: clean-dist build-rspy build-pylib build-qt add-buildhash - @echo - @echo "Build complete." + echo + echo "Build complete." .PHONY: build-rspy build-rspy: pyenv buildhash - @. pyenv/bin/activate && \ + . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ $(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)" .PHONY: build-pylib build-pylib: - @. pyenv/bin/activate && \ + . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ $(SUBMAKE) -C pylib build .PHONY: build-qt build-qt: - @. pyenv/bin/activate && \ + . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ $(SUBMAKE) -C qt build .PHONY: clean clean: clean-dist - @set -e && \ + set -e && \ for dir in $(DEVEL); do \ $(SUBMAKE) -C $$dir clean; \ done @@ -80,29 +89,29 @@ clean-dist: .PHONY: check check: pyenv buildhash - @set -e && \ + set -e && \ for dir in $(CHECKABLE_RS); do \ $(SUBMAKE) -C $$dir check; \ done; \ - . pyenv/bin/activate && \ + . 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!" + echo + echo "All checks passed!" .PHONY: fix fix: - @set -e && \ - . pyenv/bin/activate && \ + 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); \ + ver=$$(cat meta/version); \ hash=$$(cat meta/buildhash); \ rename "s/-$${ver}-/-$${ver}+$${hash}-/" dist/*-$$ver-* diff --git a/README.development b/README.development index d420fe815..6d69a9c24 100644 --- a/README.development +++ b/README.development @@ -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 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 diff --git a/pylib/Makefile b/pylib/Makefile index 34766523f..532b8d62c 100644 --- a/pylib/Makefile +++ b/pylib/Makefile @@ -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 .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables @@ -14,11 +17,11 @@ PHONY: all all: check .build/run-deps: setup.py - pip install -e . + python -m pip install -e . @touch $@ .build/dev-deps: requirements.dev - pip install -r requirements.dev + python -m pip install -r requirements.dev @touch $@ PROTODEPS := $(wildcard ../proto/*.proto) @@ -54,7 +57,7 @@ clean: # 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) mypy anki diff --git a/qt/Makefile b/qt/Makefile index 457d0012c..2cadfc1ca 100644 --- a/qt/Makefile +++ b/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 .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables @@ -14,14 +23,15 @@ PHONY: all all: check .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 $@ .build/dev-deps: requirements.dev - pip install -r requirements.dev + python -m pip install -r requirements.dev @touch $@ -.build/ui: $(shell find designer -type f) +.build/ui: $(shell ${FIND_EXEC} designer -type f) ./tools/build_ui.sh @touch $@ @@ -73,7 +83,7 @@ JSDEPS := $(patsubst ts/src/%.ts, web/%.js, $(TSDEPS)) 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 mypy aqt diff --git a/qt/i18n/copy-qt-files b/qt/i18n/copy-qt-files index fe6210b18..7905cc848 100755 --- a/qt/i18n/copy-qt-files +++ b/qt/i18n/copy-qt-files @@ -3,7 +3,15 @@ set -e out=../aqt_data/locale/qt -mkdir -p $out +mkdir -p "$out" -qtTranslations=$(python -c "from PyQt5.QtCore import *; print(QLibraryInfo.location(QLibraryInfo.TranslationsPath))") -rsync -a $qtTranslations/qt* $out +qtTranslations="$(python -c "from PyQt5.QtCore import *; import sys; sys.stdout.write(QLibraryInfo.location(QLibraryInfo.TranslationsPath))")" +unameOut="$(uname -s)" + +case "${unameOut}" in + CYGWIN*) + qtTranslations="$(cygpath -u "${qtTranslations}")" + ;; +esac + +rsync -a "$qtTranslations"/qt* "$out" diff --git a/qt/tools/extract-po-string.py b/qt/tools/extract-po-string.py index 472537567..d467ba014 100644 --- a/qt/tools/extract-po-string.py +++ b/qt/tools/extract-po-string.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# -*- coding: UTF-8 -*- import os import json import re diff --git a/qt/tools/extract_scss_colors.py b/qt/tools/extract_scss_colors.py index 6202689f3..7928b7027 100644 --- a/qt/tools/extract_scss_colors.py +++ b/qt/tools/extract_scss_colors.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python3 +# -*- coding: UTF-8 -*- import re import json diff --git a/qt/ts/package.json b/qt/ts/package.json index 985d48d41..f0c29ab8d 100644 --- a/qt/ts/package.json +++ b/qt/ts/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "Anki desktop js support files", "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", "check-pretty": "prettier --check src/*.ts" }, diff --git a/react/Makefile b/react/Makefile index 60dac2cf0..f955c3cb5 100644 --- a/react/Makefile +++ b/react/Makefile @@ -1,4 +1,6 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables diff --git a/rslib/Makefile b/rslib/Makefile index af629a269..4e322e392 100644 --- a/rslib/Makefile +++ b/rslib/Makefile @@ -1,4 +1,6 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables diff --git a/rspy/Makefile b/rspy/Makefile index fee123722..7c9ed30ea 100644 --- a/rspy/Makefile +++ b/rspy/Makefile @@ -1,4 +1,6 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables @@ -44,7 +46,7 @@ clean: RUST_TOOLCHAIN := $(shell cat 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 component add rustfmt-preview --toolchain $(RUST_TOOLCHAIN) rustup component add clippy-preview --toolchain $(RUST_TOOLCHAIN) diff --git a/run b/run index 9bbd8e2d1..7e984857d 100755 --- a/run +++ b/run @@ -1,3 +1,4 @@ #!/bin/bash +python --version make -C $(dirname $0) run RUNFLAGS="$*" diff --git a/svelte/Makefile b/svelte/Makefile index 52b217b26..7b058bc50 100644 --- a/svelte/Makefile +++ b/svelte/Makefile @@ -1,4 +1,6 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables diff --git a/tslib/Makefile b/tslib/Makefile index a8668acf8..c11b6e0e5 100644 --- a/tslib/Makefile +++ b/tslib/Makefile @@ -1,4 +1,6 @@ -SHELL := bash +SHELL := /bin/bash +ECHOCMD := /bin/echo -e + .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: MAKEFLAGS += --warn-undefined-variables