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
This commit is contained in:
evandrocoan 2020-02-25 02:32:17 -03:00
parent 0f87955a29
commit 26cdff29ec
7 changed files with 36 additions and 38 deletions

View file

@ -1,10 +1,11 @@
SHELL := /bin/bash SHELL := /bin/bash
ECHOCMD := /bin/echo -e
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
IS_WINDOWS := true PYTHON_BIN := python
ACTIVATE_SCRIPT := pyenv/Scripts/activate
else else
IS_WINDOWS := PYTHON_BIN := python3
ACTIVATE_SCRIPT := pyenv/bin/activate
endif endif
.SHELLFLAGS := -eu -o pipefail -c .SHELLFLAGS := -eu -o pipefail -c
@ -26,8 +27,8 @@ all: run
# - modern pip required for wheel # - modern pip required for wheel
# - add qt if missing # - add qt if missing
pyenv: pyenv:
python$(if ${IS_WINDOWS},,3) -m venv pyenv && \ "${PYTHON_BIN}" -m venv pyenv && \
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ . "${ACTIVATE_SCRIPT}" && \
python --version && \ python --version && \
python -m pip install --upgrade pip setuptools && \ python -m pip install --upgrade pip setuptools && \
python -c 'import PyQt5' 2>/dev/null || python -m pip install -r qt/requirements.qt python -c 'import PyQt5' 2>/dev/null || python -m pip install -r qt/requirements.qt
@ -43,37 +44,37 @@ buildhash:
.PHONY: develop .PHONY: develop
develop: pyenv buildhash develop: pyenv buildhash
set -e && \ set -eo pipefail && \
. pyenv/$(if ${IS_WINDOWS},Scripts,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
.PHONY: run .PHONY: run
run: develop run: develop
set -e && \ set -eo pipefail && \
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ . "${ACTIVATE_SCRIPT}" && \
echo "Starting Anki..."; \ echo "Starting Anki..."; \
python 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/$(if ${IS_WINDOWS},Scripts,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/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ . "${ACTIVATE_SCRIPT}" && \
$(SUBMAKE) -C pylib build $(SUBMAKE) -C pylib build
.PHONY: build-qt .PHONY: build-qt
build-qt: build-qt:
. pyenv/$(if ${IS_WINDOWS},Scripts,bin)/activate && \ . "${ACTIVATE_SCRIPT}" && \
$(SUBMAKE) -C qt build $(SUBMAKE) -C qt build
.PHONY: clean .PHONY: clean
@ -93,19 +94,19 @@ 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/$(if ${IS_WINDOWS},Scripts,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 \
$(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 -eo pipefail && \
. pyenv/$(if ${IS_WINDOWS},Scripts,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; \

View file

@ -82,9 +82,11 @@ Windows users (using Visual Studio)
1. Download and install Cygwin and put its `/bin/` directory on your system path. 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. 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. 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. 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 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 pip for your Windows Python.
1. Download and install rust (compiler), npm, git and put them your system path. 1. Download and install rust (compiler), npm, git and put them your system path.

View file

@ -1,6 +1,5 @@
SHELL := /bin/bash SHELL := /bin/bash
ECHOCMD := /bin/echo -e FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
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:
@ -57,7 +56,7 @@ clean:
# Checking python # 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) .build/mypy: $(CHECKDEPS)
mypy anki mypy anki

View file

@ -1,11 +1,10 @@
SHELL := /bin/bash SHELL := /bin/bash
ECHOCMD := /bin/echo -e FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
FIND_EXEC := $(if $(wildcard /bin/find),,/usr)/bin/find
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
IS_WINDOWS := true INSTALL_PYAUDIO := python -m pip install git+https://github.com/evandroforks/pyaudio
else else
IS_WINDOWS := INSTALL_PYAUDIO := @echo Skipping pyaudio for Windows...
endif endif
.SHELLFLAGS := -eu -o pipefail -c .SHELLFLAGS := -eu -o pipefail -c
@ -23,7 +22,7 @@ PHONY: all
all: check all: check
.build/run-deps: setup.py .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 . python -m pip install -e .
@touch $@ @touch $@
@ -31,7 +30,7 @@ all: check
python -m pip install -r requirements.dev python -m pip install -r requirements.dev
@touch $@ @touch $@
.build/ui: $(shell ${FIND_EXEC} designer -type f) .build/ui: $(shell ${FIND} designer -type f)
./tools/build_ui.sh ./tools/build_ui.sh
@touch $@ @touch $@
@ -83,7 +82,7 @@ JSDEPS := $(patsubst ts/src/%.ts, web/%.js, $(TSDEPS))
PYLIB := ../pylib 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 .build/mypy: $(CHECKDEPS) .build/qt-stubs
mypy aqt mypy aqt

View file

@ -1,5 +1,4 @@
SHELL := /bin/bash SHELL := /bin/bash
ECHOCMD := /bin/echo -e
.SHELLFLAGS := -eu -o pipefail -c .SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR: .DELETE_ON_ERROR:

View file

@ -1,6 +1,5 @@
SHELL := /bin/bash SHELL := /bin/bash
ECHOCMD := /bin/echo -e FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
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:
@ -26,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_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 # nightly currently required for ignoring files in rustfmt.toml
RUST_TOOLCHAIN := $(shell cat rust-toolchain) RUST_TOOLCHAIN := $(shell cat rust-toolchain)

View file

@ -1,6 +1,5 @@
SHELL := /bin/bash SHELL := /bin/bash
ECHOCMD := /bin/echo -e FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
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:
@ -22,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_EXEC} ../rslib/src -name '*.rs') $(wildcard ../proto/*) \ $(shell ${FIND} ../rslib/src -name '*.rs') $(wildcard ../proto/*) \
$(shell ${FIND_EXEC} ../rslib/ftl -type f) $(shell ${FIND} ../rslib/ftl -type f)
.build/develop: $(DEPS) .build/develop: $(DEPS)
touch ../proto/backend.proto touch ../proto/backend.proto