From 26cdff29ec1979ced29dd17d0b80326de90eab22 Mon Sep 17 00:00:00 2001 From: evandrocoan Date: Tue, 25 Feb 2020 02:32:17 -0300 Subject: [PATCH] Renamed FIND_EXEC to FIND, replaced IS_WINDOWS by specific commands as PYTHON_BIN, ACTIVE_SCRIPT and INSTALL_PYAUDIO. Fixed echo statements not using @ to suppress double message output. Deprecated the usage of ECHOCMD := /bin/echo -e because it has no effect: https://stackoverflow.com/questions/60387684/how-to-make-the-makefile-echos-to-use-bin-echo-e # Conflicts: # Makefile --- Makefile | 39 ++++++++++++++++++++------------------- README.development | 4 +++- pylib/Makefile | 5 ++--- qt/Makefile | 13 ++++++------- react/Makefile | 1 - rslib/Makefile | 5 ++--- rspy/Makefile | 7 +++---- 7 files changed, 36 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index e2273071f..2dd4d4bf9 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e ifeq ($(OS),Windows_NT) - IS_WINDOWS := true + PYTHON_BIN := python + ACTIVATE_SCRIPT := pyenv/Scripts/activate else - IS_WINDOWS := + PYTHON_BIN := python3 + ACTIVATE_SCRIPT := pyenv/bin/activate endif .SHELLFLAGS := -eu -o pipefail -c @@ -26,8 +27,8 @@ 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_BIN}" -m venv pyenv && \ + . "${ACTIVATE_SCRIPT}" && \ python --version && \ python -m pip install --upgrade pip setuptools && \ python -c 'import PyQt5' 2>/dev/null || python -m pip install -r qt/requirements.qt @@ -43,37 +44,37 @@ buildhash: .PHONY: develop develop: pyenv buildhash - set -e && \ - . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + set -eo pipefail && \ + . "${ACTIVATE_SCRIPT}" && \ 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 && \ + set -eo pipefail && \ + . "${ACTIVATE_SCRIPT}" && \ echo "Starting Anki..."; \ 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/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + . "${ACTIVATE_SCRIPT}" && \ $(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)" .PHONY: build-pylib build-pylib: - . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + . "${ACTIVATE_SCRIPT}" && \ $(SUBMAKE) -C pylib build .PHONY: build-qt build-qt: - . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + . "${ACTIVATE_SCRIPT}" && \ $(SUBMAKE) -C qt build .PHONY: clean @@ -93,19 +94,19 @@ check: pyenv buildhash for dir in $(CHECKABLE_RS); do \ $(SUBMAKE) -C $$dir check; \ done; \ - . pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + . "${ACTIVATE_SCRIPT}" && \ $(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/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ + set -eo pipefail && \ + . "${ACTIVATE_SCRIPT}" && \ for dir in $(CHECKABLE_RS) $(CHECKABLE_PY); do \ $(SUBMAKE) -C $$dir fix; \ done; \ diff --git a/README.development b/README.development index bbfacdd7e..fc45458e6 100644 --- a/README.development +++ b/README.development @@ -82,9 +82,11 @@ 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. If the Cygwin `/usr/bin/` directory exists, move all files from `/usr/bin/` to `/bin/`. 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. 1. Download and install rust (compiler), npm, git and put them your system path. diff --git a/pylib/Makefile b/pylib/Makefile index 532b8d62c..c78af5bf4 100644 --- a/pylib/Makefile +++ b/pylib/Makefile @@ -1,6 +1,5 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e -FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find +FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: @@ -57,7 +56,7 @@ clean: # Checking python ###################### -CHECKDEPS := $(shell ${FIND_EXEC} anki tests -name '*.py' | grep -v buildinfo.py) +CHECKDEPS := $(shell ${FIND} anki tests -name '*.py' | grep -v buildinfo.py) .build/mypy: $(CHECKDEPS) mypy anki diff --git a/qt/Makefile b/qt/Makefile index 2cadfc1ca..bca95a466 100644 --- a/qt/Makefile +++ b/qt/Makefile @@ -1,11 +1,10 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e -FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find +FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) ifeq ($(OS),Windows_NT) - IS_WINDOWS := true + INSTALL_PYAUDIO := python -m pip install git+https://github.com/evandroforks/pyaudio else - IS_WINDOWS := + INSTALL_PYAUDIO := @echo Skipping pyaudio for Windows... endif .SHELLFLAGS := -eu -o pipefail -c @@ -23,7 +22,7 @@ PHONY: all all: check .build/run-deps: setup.py - $(if ${IS_WINDOWS},python -m pip install git+https://github.com/evandroforks/pyaudio,) + ${INSTALL_PYAUDIO} python -m pip install -e . @touch $@ @@ -31,7 +30,7 @@ all: check python -m pip install -r requirements.dev @touch $@ -.build/ui: $(shell ${FIND_EXEC} designer -type f) +.build/ui: $(shell ${FIND} designer -type f) ./tools/build_ui.sh @touch $@ @@ -83,7 +82,7 @@ JSDEPS := $(patsubst ts/src/%.ts, web/%.js, $(TSDEPS)) PYLIB := ../pylib -CHECKDEPS := $(shell ${FIND_EXEC} 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 mypy aqt diff --git a/react/Makefile b/react/Makefile index f955c3cb5..d39a2cf90 100644 --- a/react/Makefile +++ b/react/Makefile @@ -1,5 +1,4 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: diff --git a/rslib/Makefile b/rslib/Makefile index 4c09cada8..58cbadfbe 100644 --- a/rslib/Makefile +++ b/rslib/Makefile @@ -1,6 +1,5 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e -FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find +FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: @@ -26,7 +25,7 @@ develop: .build/vernum ftl/repo ftl/repo: (cd ftl && ./scripts/fetch-latest-translations) -ALL_SOURCE := $(shell ${FIND_EXEC} 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 RUST_TOOLCHAIN := $(shell cat rust-toolchain) diff --git a/rspy/Makefile b/rspy/Makefile index 7af93253f..787857e90 100644 --- a/rspy/Makefile +++ b/rspy/Makefile @@ -1,6 +1,5 @@ SHELL := /bin/bash -ECHOCMD := /bin/echo -e -FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find +FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) .SHELLFLAGS := -eu -o pipefail -c .DELETE_ON_ERROR: @@ -22,8 +21,8 @@ all: develop develop: .build/develop DEPS := .build/tools .build/vernum ../meta/buildhash $(wildcard $(QT_FTLS)/*.ftl) \ - $(shell ${FIND_EXEC} ../rslib/src -name '*.rs') $(wildcard ../proto/*) \ - $(shell ${FIND_EXEC} ../rslib/ftl -type f) + $(shell ${FIND} ../rslib/src -name '*.rs') $(wildcard ../proto/*) \ + $(shell ${FIND} ../rslib/ftl -type f) .build/develop: $(DEPS) touch ../proto/backend.proto