Merge pull request #528 from evandroforks/create_actions_for_windows_macos

Create actions for Windows and Mac OS
This commit is contained in:
Damien Elmes 2020-03-27 15:26:22 +10:00 committed by GitHub
commit f6219b59ac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 381 additions and 90 deletions

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -eo pipefail set -eu -o pipefail ${SHELLFLAGS}
antispam=", at the domain " antispam=", at the domain "

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -eo pipefail set -eu -o pipefail ${SHELLFLAGS}
# Checking version to force it fail the build if rg is not installed. # Checking version to force it fail the build if rg is not installed.
# Because `set -e` does not work inside the subshell $() # Because `set -e` does not work inside the subshell $()

View file

@ -3,27 +3,239 @@ name: Checks
on: [push, pull_request] on: [push, pull_request]
jobs: jobs:
test: tests:
runs-on: ubuntu-latest name: ${{ matrix.os }} ${{ matrix.BUILD_TYPE }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
BUILD_TYPE: [check, build]
include:
- os: ubuntu-latest
SEP: /
PIP_WHEELS_DIR: ~/.cache/pip
CARGO_INDEX_DIR: ~/.cargo/git
CARGO_REGISTRY_DIR: ~/.cargo/registry
ANKI_PYTHON_WHEELS: anki_linux_python_wheels
- os: macos-latest
SEP: /
PIP_WHEELS_DIR: ~/Library/Caches/pip
CARGO_INDEX_DIR: ~/.cargo/git
CARGO_REGISTRY_DIR: ~/.cargo/registry
ANKI_PYTHON_WHEELS: anki_macos_python_wheels
- os: windows-latest
SEP: \
PIP_WHEELS_DIR: ~\AppData\Local\pip\Cache
CARGO_INDEX_DIR: C:\Rust\.cargo\git
CARGO_REGISTRY_DIR: C:\Rust\.cargo\registry
ANKI_PYTHON_WHEELS: anki_windows_python_wheels
# Keep running all matrices if something fail
fail-fast: false
steps: steps:
- run: git config --global core.autocrlf false
if: matrix.os == 'windows-latest'
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Configure Linux environment variables
if: matrix.os == 'ubuntu-latest'
run: |
# echo "::set-env name=SHELLFLAGS::-x"
echo "::set-env name=BUILDFLAGS::"
echo "::set-env name=RSPY_TARGET_DIR::${GITHUB_WORKSPACE}/target"
echo "::set-env name=CARGO_TARGET_DIR::${GITHUB_WORKSPACE}/target"
- name: Configure Mac OS environment variables
if: matrix.os == 'macos-latest'
run: |
# echo "::set-env name=SHELLFLAGS::-x"
echo "::set-env name=BUILDFLAGS::"
# Disabled for Mac OS because it was not reusing the cached files
# https://github.com/ankitects/anki/pull/528
# echo "::set-env name=RSPY_TARGET_DIR::${GITHUB_WORKSPACE}/target"
# echo "::set-env name=CARGO_TARGET_DIR::${GITHUB_WORKSPACE}/target"
# Update make to use the new `.SHELLFLAGS` feature
# https://stackoverflow.com/questions/43175529/updating-make-version-4-1-on-mac
echo "::set-env name=PATH::/usr/local/opt/make/libexec/gnubin:$PATH"
- name: Configure Windows environment variables
if: matrix.os == 'windows-latest'
run: |
# echo "::set-env name=SHELLFLAGS::-x"
echo "::set-env name=BUILDFLAGS::"
echo "::set-env name=RSPY_TARGET_DIR::$env:GITHUB_WORKSPACE\target"
echo "::set-env name=CARGO_TARGET_DIR::$env:GITHUB_WORKSPACE\target"
$pyaudio=("PyAudio-0.2.11-cp37-cp37m-win_amd64.whl")
$new_path=("$env:GITHUB_WORKSPACE;$env:PATH")
$new_path=("$env:GITHUB_WORKSPACE\shims;$new_path")
echo "::set-env name=pacmanbin::pacman-5.1.1-3-x86_64.pkg.tar.xz"
echo "::set-env name=pacmanmirror::pacman-mirrors-20200307-1-any.pkg.tar.xz"
echo "::set-env name=pacmankeys::msys2-keyring-r9.397a52e-1-any.pkg.tar.xz"
echo "::set-env name=pyaudio::$pyaudio"
echo "::set-env name=PATH::$new_path"
echo "::set-env name=RUST_BACKTRACE::full"
echo "::set-env name=SCOOP::$env:GITHUB_WORKSPACE"
echo "::set-env name=SCOOP_GLOBAL::$env:GITHUB_WORKSPACE"
echo "::set-env name=ANKI_EXTRA_PIP::python -m pip install $pyaudio"
# Necessary for now for the cargo cache:
# https://github.com/actions/cache/issues/133#issuecomment-599102035
- name: Fix ~/.cache permissions
if: matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest'
run: |
sudo chown -R $(whoami):$(id -ng) ~/.cargo/
- name: Cache pyenv
uses: actions/cache@v1
with:
path: ${{ github.workspace }}${{ matrix.SEP }}pyenv
key: ${{ runner.os }}-pyenv-${{ hashFiles('**/Makefile') }}-${{ hashFiles('**/requirements.txt') }}-14-
# Disabling these caches for now because they do not seem to be used/help
# https://github.com/ankitects/anki/pull/528
# - name: Cache pip wheels
# uses: actions/cache@v1
# with:
# path: ${{ matrix.PIP_WHEELS_DIR }}
# key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}-14-
- name: Cache cargo index
uses: actions/cache@v1
with:
path: ${{ matrix.CARGO_INDEX_DIR }}
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.toml') }}-14-
- name: Cache cargo registry
uses: actions/cache@v1
with:
path: ${{ matrix.CARGO_REGISTRY_DIR }}
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.toml') }}-14-
- name: Cache cargo target
uses: actions/cache@v1
with:
path: ${{ github.workspace }}${{ matrix.SEP }}target
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.BUILD_TYPE }}-14-
- name: Cache cargo rslib
uses: actions/cache@v1
with:
path: ${{ github.workspace }}${{ matrix.SEP }}rslib${{ matrix.SEP }}target
key: ${{ runner.os }}-cargo-rslib-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.BUILD_TYPE }}-14-
- name: Cache cargo rspy
uses: actions/cache@v1
with:
path: ${{ github.workspace }}${{ matrix.SEP }}rspy${{ matrix.SEP }}target
key: ${{ runner.os }}-cargo-rspy-${{ hashFiles('**/Cargo.toml') }}-${{ matrix.BUILD_TYPE }}-14-
- name: Cache pacman
if: matrix.os == 'windows-latest'
uses: actions/cache@v1
id: cache-pacman
with:
path: C:\Program Files\Git
key: ${{ runner.os }}-pacman-${{ hashFiles('**/checks.yml') }}-14-
- name: Set up pacman, rsync
if: matrix.os == 'windows-latest' && steps.cache-pacman.outputs.cache-hit != 'true'
shell: cmd
run: |
echo on
curl -LO http://repo.msys2.org/msys/x86_64/%pacmanbin%
curl -LO http://repo.msys2.org/msys/x86_64/%pacmanmirror%
curl -LO http://repo.msys2.org/msys/x86_64/%pacmankeys%
:: https://stackoverflow.com/questions/1359793/programmatically-extract-tar-gz
7z x "%pacmanbin%" -so | 7z x -aoa -si -ttar -o"%programfiles%\Git"
7z x "%pacmanmirror%" -so | 7z x -aoa -si -ttar -o"%programfiles%\Git"
7z x "%pacmankeys%" -so | 7z x -aoa -si -ttar -o"%programfiles%\Git"
:: Manually Install Pacman Binaries
:: https://github.com/Alexpux/MSYS2-pacman/issues/50
set "PATH=%programfiles%\Git\usr\bin"
bash pacman-key --init
bash pacman-key --populate msys2
bash pacman-key --refresh-keys
pacman -Tv
pacman -Syyuuv --overwrite='*'
pacman -Syuuv --overwrite='*'
pacman --version
:: We must install bash first, otherwise we will have bash fork errors:
:: https://github.com/evandroforks/anki/runs/524857054?check_suite_focus=true
:: 0 [main] pacman 748 dofork: child -1 - forked process 2896 died unexpectedly
pacman -Sv --noconfirm --overwrite='*' bash
pacman -Sv --noconfirm --overwrite='*' rsync
:: clean all packages to decrease image size
pacman -Sccv --noconfirm
pacman -Qsv --noconfirm
- name: Set up curl pyaudio, rename
if: matrix.os == 'windows-latest'
shell: cmd
run: |
echo on
curl -LO https://download.lfd.uci.edu/pythonlibs/s2jqpv5t/%pyaudio%
curl -LO https://raw.githubusercontent.com/subogero/rename/master/rename
- name: Set up Windows scoop, gettext, ripgrep
if: matrix.os == 'windows-latest'
shell: cmd
run: |
echo on
powershell -executionpolicy bypass "& Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')"
scoop install -g gettext ripgrep
- name: Set up Ubuntu ripgrep, pyaudio, gettext, rename
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update
sudo apt install portaudio19-dev gettext rename
sudo snap install ripgrep --classic
- name: Set up brew ripgrep, pyaudio, gettext, rename
if: matrix.os == 'macos-latest'
run: |
brew install portaudio protobuf gettext rename ripgrep make
brew link gettext --force
- name: Set up python - name: Set up python
uses: actions/setup-python@v1 uses: actions/setup-python@v1
with: with:
python-version: 3.7 python-version: 3.7
- name: Set up protoc - name: Set up protoc
uses: ankitects/setup-protoc@master uses: ankitects/setup-protoc@master
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up node - name: Set up node
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: 12 node-version: 12
- name: Run checks
run: | - run: make develop
# add requirements if: matrix.BUILD_TYPE != 'check'
sudo apt update; sudo apt install portaudio19-dev gettext rename
sudo snap install ripgrep --classic - run: make build
export CARGO_TARGET_DIR=~/target if: matrix.BUILD_TYPE != 'check'
export RSPY_TARGET_DIR=~/target
make check build BUILDFLAGS="" - run: make check
if: matrix.BUILD_TYPE == 'check'
- name: Upload python wheels
if: matrix.BUILD_TYPE != 'check'
uses: actions/upload-artifact@v1
with:
name: ${{ matrix.ANKI_PYTHON_WHEELS }}
path: dist

1
.gitignore vendored
View file

@ -6,6 +6,7 @@
.build .build
.coverage .coverage
.DS_Store .DS_Store
rename
dist dist
pyenv pyenv
.mypy_cache .mypy_cache

View file

@ -1,10 +1,23 @@
SHELL := /bin/bash SHELL := /bin/bash
ifndef SHELLFLAGS
SHELLFLAGS :=
endif
.SHELLFLAGS := -eu -o pipefail ${SHELLFLAGS} -c
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
ifndef OS ifndef OS
OS := unknown OS := unknown
endif endif
ifeq (${OS},Windows_NT) ifeq (${OS},Windows_NT)
# Windows terminal is confusing it with its `cmd` builtin `rename` command
ifndef RENAME_BIN
RENAME_BIN := perl rename
endif
ifndef ACTIVATE_SCRIPT ifndef ACTIVATE_SCRIPT
ACTIVATE_SCRIPT := pyenv/Scripts/activate ACTIVATE_SCRIPT := pyenv/Scripts/activate
endif endif
@ -13,6 +26,10 @@ ifeq (${OS},Windows_NT)
PYTHON_BIN := python PYTHON_BIN := python
endif endif
else else
ifndef RENAME_BIN
RENAME_BIN := rename
endif
ifndef ACTIVATE_SCRIPT ifndef ACTIVATE_SCRIPT
ACTIVATE_SCRIPT := pyenv/bin/activate ACTIVATE_SCRIPT := pyenv/bin/activate
endif endif
@ -26,10 +43,7 @@ ifndef ANKI_EXTRA_PIP
ANKI_EXTRA_PIP := true ANKI_EXTRA_PIP := true
endif endif
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR: .DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
SUBMAKE := $(MAKE) --print-directory SUBMAKE := $(MAKE) --print-directory
.SUFFIXES: .SUFFIXES:
@ -46,17 +60,31 @@ all: run
# - modern pip required for wheel # - modern pip required for wheel
# - add qt if missing # - add qt if missing
pyenv: pyenv:
"${PYTHON_BIN}" -m venv pyenv && \ # https://github.com/PyO3/maturin/issues/283
. "${ACTIVATE_SCRIPT}" && \ # Expected `python` to be a python interpreter inside a virtualenv
python --version && \ set -eu -o pipefail ${SHELLFLAGS}; \
python -m pip install --upgrade pip setuptools && \ "${PYTHON_BIN}" -m pip install virtualenv; \
${ANKI_EXTRA_PIP} && \ "${PYTHON_BIN}" -m venv pyenv; \
python -c 'import PyQt5' 2>/dev/null || python -m pip install -r qt/requirements.qt case "$$(uname -s)" in CYGWIN*|MINGW*|MSYS*) \
dos2unix "${ACTIVATE_SCRIPT}"; \
VIRTUAL_ENV="$$(pwd)"; \
VIRTUAL_ENV="$$(cygpath -m "$${VIRTUAL_ENV}")"; \
sed -i -- "s@VIRTUAL_ENV=\".*\"@VIRTUAL_ENV=\"$$(pwd)/pyenv\"@g" "${ACTIVATE_SCRIPT}"; \
sed -i -- "s@export PATH@export PATH; VIRTUAL_ENV=\"$${VIRTUAL_ENV}/pyenv\";@g" "${ACTIVATE_SCRIPT}"; \
;; esac; \
. "${ACTIVATE_SCRIPT}"; \
python --version; \
python -m pip install --upgrade pip setuptools; \
${ANKI_EXTRA_PIP}; \
if ! python -c 'import PyQt5' 2>/dev/null; then \
python -m pip install -r qt/requirements.qt; \
fi;
# update build hash # update build hash
.PHONY: buildhash .PHONY: buildhash
buildhash: buildhash:
@oldhash=$$(test -f meta/buildhash && cat meta/buildhash || true); \ @set -eu -o pipefail ${SHELLFLAGS}; \
oldhash=$$(test -f meta/buildhash && cat meta/buildhash || true); \
newhash=$$(git rev-parse --short=8 HEAD || echo dev); \ newhash=$$(git rev-parse --short=8 HEAD || echo dev); \
if [ "$$oldhash" != "$$newhash" ]; then \ if [ "$$oldhash" != "$$newhash" ]; then \
echo $$newhash > meta/buildhash; \ echo $$newhash > meta/buildhash; \
@ -64,16 +92,16 @@ buildhash:
.PHONY: develop .PHONY: develop
develop: pyenv buildhash prepare develop: pyenv buildhash prepare
@set -eo pipefail && \ @set -eu -o pipefail ${SHELLFLAGS}; \
. "${ACTIVATE_SCRIPT}" && \ . "${ACTIVATE_SCRIPT}"; \
for dir in $(DEVEL); do \ for dir in $(DEVEL); do \
$(SUBMAKE) -C $$dir develop DEVFLAGS="$(DEVFLAGS)"; \ $(SUBMAKE) -C $$dir develop DEVFLAGS="$(DEVFLAGS)"; \
done done
.PHONY: run .PHONY: run
run: develop run: develop
@set -eo pipefail && \ @set -eu -o pipefail ${SHELLFLAGS}; \
. "${ACTIVATE_SCRIPT}" && \ . "${ACTIVATE_SCRIPT}"; \
echo "Starting Anki..."; \ echo "Starting Anki..."; \
python qt/runanki $(RUNFLAGS) python qt/runanki $(RUNFLAGS)
@ -94,22 +122,25 @@ 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
@. "${ACTIVATE_SCRIPT}" && \ @set -eu -o pipefail ${SHELLFLAGS}; \
. "${ACTIVATE_SCRIPT}"; \
$(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)" $(SUBMAKE) -C rspy build BUILDFLAGS="$(BUILDFLAGS)"
.PHONY: build-pylib .PHONY: build-pylib
build-pylib: build-pylib:
@. "${ACTIVATE_SCRIPT}" && \ @set -eu -o pipefail ${SHELLFLAGS}; \
. "${ACTIVATE_SCRIPT}"; \
$(SUBMAKE) -C pylib build $(SUBMAKE) -C pylib build
.PHONY: build-qt .PHONY: build-qt
build-qt: build-qt:
@. "${ACTIVATE_SCRIPT}" && \ @set -eu -o pipefail ${SHELLFLAGS}; \
. "${ACTIVATE_SCRIPT}"; \
$(SUBMAKE) -C qt build $(SUBMAKE) -C qt build
.PHONY: clean .PHONY: clean
clean: clean-dist clean: clean-dist
@set -eo pipefail && \ @set -eu -o pipefail ${SHELLFLAGS}; \
for dir in $(DEVEL); do \ for dir in $(DEVEL); do \
$(SUBMAKE) -C $$dir clean; \ $(SUBMAKE) -C $$dir clean; \
done done
@ -120,14 +151,14 @@ clean-dist:
.PHONY: check .PHONY: check
check: pyenv buildhash prepare check: pyenv buildhash prepare
@set -eo pipefail && \ @set -eu -o pipefail ${SHELLFLAGS}; \
.github/scripts/trailing-newlines.sh && \ .github/scripts/trailing-newlines.sh; \
for dir in $(CHECKABLE_RS); do \ for dir in $(CHECKABLE_RS); do \
$(SUBMAKE) -C $$dir check; \ $(SUBMAKE) -C $$dir check; \
done && \ done; \
. "${ACTIVATE_SCRIPT}" && \ . "${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;
@ -136,17 +167,21 @@ check: pyenv buildhash prepare
.PHONY: fix .PHONY: fix
fix: fix:
@set -eo pipefail && \ @set -eu -o pipefail ${SHELLFLAGS}; \
. "${ACTIVATE_SCRIPT}" && \ . "${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; \
.PHONY: add-buildhash .PHONY: add-buildhash
add-buildhash: add-buildhash:
@ver=$$(cat meta/version); \ @set -eu -o pipefail ${SHELLFLAGS}; \
hash=$$(cat meta/buildhash); \ if [[ ! -f rename ]]; then \
rename "s/-$${ver}-/-$${ver}+$${hash}-/" dist/*-$$ver-* curl --silent -LO https://raw.githubusercontent.com/subogero/rename/master/rename; \
fi; \
ver="$$(cat meta/version)"; \
hash="$$(cat meta/buildhash)"; \
${RENAME_BIN} "s/-$${ver}-/-$${ver}+$${hash}-/" dist/*-"$${ver}"-*
.PHONY: pull-i18n .PHONY: pull-i18n

View file

@ -114,7 +114,7 @@ You can do this automatically by adding the following into
.git/hooks/pre-commit or .git/hooks/pre-push and making it executable. .git/hooks/pre-commit or .git/hooks/pre-push and making it executable.
#!/bin/bash #!/bin/bash
set -eo pipefail set -eu -o pipefail ${SHELLFLAGS}
make check make check
You may need to adjust the PATH variable so that things like a local install You may need to adjust the PATH variable so that things like a local install

View file

@ -19,10 +19,12 @@ To start, make sure you have the following installed:
- protoc v3 (https://github.com/protocolbuffers/protobuf/releases) - protoc v3 (https://github.com/protocolbuffers/protobuf/releases)
- rustup (https://rustup.rs/) - rustup (https://rustup.rs/)
- gettext - gettext
- rename - rename (from the perl script https://github.com/subogero/rename)
- rsync - rsync
- perl - perl
- ripgrep (cargo install rigrep) - ripgrep (cargo install rigrep)
- git
- curl
The build scripts assume a UNIX-like environment, so on Windows you will The build scripts assume a UNIX-like environment, so on Windows you will
need to use WSL or Cygwin to use them. need to use WSL or Cygwin to use them.
@ -60,6 +62,10 @@ folder.
Use 'make clean' to remove some generated files. Use 'make clean' to remove some generated files.
To see all commands run by make or any shell script, export the environment
variable SHELLFLAGS with '-x' to tell shell to print all commands run by it.
For example, 'export SHELLFLAGS=-x' on Linux or 'set SHELLFLAGS=-x' on Windows.
PyQt PyQt
----- -----
@ -73,7 +79,7 @@ Mac users
You can use homebrew to install some dependencies: 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 ripgrep
$ brew link gettext --force $ brew link gettext --force

View file

@ -1,25 +1,27 @@
SHELL := /bin/bash SHELL := /bin/bash
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
ifndef SHELLFLAGS
SHELLFLAGS :=
endif
.SHELLFLAGS := -eu -o pipefail ${SHELLFLAGS} -c
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
RUNARGS :=
MYPY_ARGS := MYPY_ARGS :=
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
ifndef OS ifndef OS
OS := unknown OS := unknown
endif endif
ifndef UNAME
UNAME := unknown
endif
# https://anki.tenderapp.com/discussions/beta-testing/1860-error-unused-type-ignore-comment # https://anki.tenderapp.com/discussions/beta-testing/1860-error-unused-type-ignore-comment
ifneq (${OS},Windows_NT) ifneq (${OS},Windows_NT)
MYPY_ARGS := --warn-unused-ignores MYPY_ARGS := --warn-unused-ignores
endif endif
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR: .DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
RUNARGS :=
.SUFFIXES: .SUFFIXES:
BLACKARGS := -t py36 anki tests setup.py tools/*.py --exclude='_pb2|buildinfo' BLACKARGS := -t py36 anki tests setup.py tools/*.py --exclude='_pb2|buildinfo'
ISORTARGS := anki tests setup.py ISORTARGS := anki tests setup.py

View file

@ -1,4 +1,13 @@
SHELL := /bin/bash SHELL := /bin/bash
ifndef SHELLFLAGS
SHELLFLAGS :=
endif
.SHELLFLAGS := -eu -o pipefail ${SHELLFLAGS} -c
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
MYPY_ARGS := MYPY_ARGS :=
PYLINT_ARGS := PYLINT_ARGS :=
@ -7,10 +16,6 @@ ifndef OS
OS := unknown OS := unknown
endif endif
ifndef UNAME
UNAME := unknown
endif
# https://anki.tenderapp.com/discussions/beta-testing/1860-error-unused-type-ignore-comment # https://anki.tenderapp.com/discussions/beta-testing/1860-error-unused-type-ignore-comment
ifneq (${OS},Windows_NT) ifneq (${OS},Windows_NT)
MYPY_ARGS := --warn-unused-ignores MYPY_ARGS := --warn-unused-ignores
@ -18,10 +23,7 @@ else
PYLINT_ARGS := --ignored-modules=win32file,pywintypes,socket,win32pipe PYLINT_ARGS := --ignored-modules=win32file,pywintypes,socket,win32pipe
endif endif
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR: .DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
.SUFFIXES: .SUFFIXES:
BLACKARGS := -t py36 aqt tests setup.py tools/*.py --exclude='aqt/forms|buildinfo|colors' BLACKARGS := -t py36 aqt tests setup.py tools/*.py --exclude='aqt/forms|buildinfo|colors'

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
set -eu -o pipefail ${SHELLFLAGS}
echo "Downloading latest translations..." echo "Downloading latest translations..."
if [ ! -d repo ]; then if [ ! -d repo ]; then

View file

@ -3,6 +3,8 @@
# expects to be run from the ftl folder # expects to be run from the ftl folder
# #
set -eu -o pipefail ${SHELLFLAGS}
test -d repo || exit 1 test -d repo || exit 1
rsync -av --delete *.ftl repo/desktop/templates/ rsync -av --delete *.ftl repo/desktop/templates/

View file

@ -2,7 +2,8 @@
# #
# build mo files # build mo files
# #
set -eo pipefail
set -eu -o pipefail ${SHELLFLAGS}
targetDir="../aqt_data/locale/gettext" targetDir="../aqt_data/locale/gettext"
mkdir -p $targetDir mkdir -p $targetDir

View file

@ -1,15 +1,14 @@
#!/bin/bash #!/bin/bash
set -eo pipefail set -eu -o pipefail ${SHELLFLAGS}
out=../aqt_data/locale/qt out=../aqt_data/locale/qt
mkdir -p "$out" mkdir -p "$out"
qtTranslations="$(python -c "from PyQt5.QtCore import *; import sys; sys.stdout.write(QLibraryInfo.location(QLibraryInfo.TranslationsPath))")" qtTranslations="$(python -c "from PyQt5.QtCore import *; import sys; sys.stdout.write(QLibraryInfo.location(QLibraryInfo.TranslationsPath))")"
unameOut="$(uname -s)"
case "${unameOut}" in case "$(uname -s)" in
CYGWIN*) CYGWIN*|MINGW*|MSYS*)
qtTranslations="$(cygpath -u "${qtTranslations}")" qtTranslations="$(cygpath -u "${qtTranslations}")"
;; ;;
esac esac

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
set -eu -o pipefail ${SHELLFLAGS}
echo "Downloading latest translations..." echo "Downloading latest translations..."
if [ ! -d repo ]; then if [ ! -d repo ]; then

View file

@ -2,7 +2,8 @@
# #
# update template .pot file from source code strings # update template .pot file from source code strings
# #
set -eo pipefail
set -eu -o pipefail ${SHELLFLAGS}
topDir=$(dirname $0)/../../../ topDir=$(dirname $0)/../../../
cd $topDir cd $topDir

View file

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
set -eo pipefail set -eu -o pipefail ${SHELLFLAGS}
scripts/update-po-template scripts/update-po-template
(cd repo && git add desktop; git commit -m update; git push) (cd repo && git add desktop; git commit -m update; git push)

View file

@ -4,7 +4,7 @@
# should be on the path. # should be on the path.
# #
set -eo pipefail set -eu -o pipefail ${SHELLFLAGS}
if [ ! -d "designer" ] if [ ! -d "designer" ]
then then

View file

@ -6,14 +6,18 @@
# able to resolve. A solution that doesn't require modifying the python install # able to resolve. A solution that doesn't require modifying the python install
# would be welcome! # would be welcome!
set -eo pipefail set -eu -o pipefail ${SHELLFLAGS}
# https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash
if [[ -z "${OS+x}" ]]; then
OS=unknown;
fi
TOOLS="$(cd "`dirname "$0"`"; pwd)" TOOLS="$(cd "`dirname "$0"`"; pwd)"
modDir=$(python -c 'import PyQt5, sys, os; sys.stdout.write(os.path.dirname(sys.modules["PyQt5"].__file__))') modDir=$(python -c 'import PyQt5, sys, os; sys.stdout.write(os.path.dirname(sys.modules["PyQt5"].__file__))')
unameOut="$(uname -s)" case "$(uname -s)" in
case "${unameOut}" in CYGWIN*|MINGW*|MSYS*)
CYGWIN*)
modDir="$(cygpath -u "${modDir}")" modDir="$(cygpath -u "${modDir}")"
;; ;;
esac esac

View file

@ -1,11 +1,16 @@
SHELL := /bin/bash SHELL := /bin/bash
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
.SHELLFLAGS := -eu -o pipefail -c ifndef SHELLFLAGS
.DELETE_ON_ERROR: SHELLFLAGS :=
endif
.SHELLFLAGS := -eu -o pipefail ${SHELLFLAGS} -c
MAKEFLAGS += --warn-undefined-variables MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules MAKEFLAGS += --no-builtin-rules
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
.DELETE_ON_ERROR:
$(shell mkdir -p .build) $(shell mkdir -p .build)
.PHONY: all check fix clean develop .PHONY: all check fix clean develop

View file

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
set -eu -o pipefail ${SHELLFLAGS}
echo "Downloading latest translations..." echo "Downloading latest translations..."
if [ ! -d repo ]; then if [ ! -d repo ]; then

View file

@ -3,6 +3,8 @@
# expects to be run from the ftl folder # expects to be run from the ftl folder
# #
set -eu -o pipefail ${SHELLFLAGS}
test -d repo || exit 1 test -d repo || exit 1
rsync -av --delete *.ftl repo/core/templates/ rsync -av --delete *.ftl repo/core/templates/

View file

@ -1,4 +1,13 @@
SHELL := /bin/bash SHELL := /bin/bash
ifndef SHELLFLAGS
SHELLFLAGS :=
endif
.SHELLFLAGS := -eu -o pipefail ${SHELLFLAGS} -c
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find) FIND := $(if $(wildcard /bin/find),/bin/find,/usr/bin/find)
ifndef OS ifndef OS
@ -6,20 +15,22 @@ ifndef OS
endif endif
ifeq (${OS},Windows_NT) ifeq (${OS},Windows_NT)
ifndef PYTHON_BIN ifndef PYTHON_FILE
PYTHON_BIN := python PYTHON_FILE := $(shell which python)
USE_CYGPATH_COMMAND := case "$$(uname -s)" in CYGWIN*|MINGW*|MSYS*) printf "yes";; esac;
USE_CYGPATH := $(shell ${USE_CYGPATH_COMMAND})
ifneq (,${USE_CYGPATH})
PYTHON_FILE := $(shell cygpath -w "${PYTHON_FILE}")
endif
endif endif
else else
ifndef PYTHON_BIN ifndef PYTHON_FILE
PYTHON_BIN := python3 PYTHON_FILE := $(shell which python3)
endif endif
endif endif
.SHELLFLAGS := -eu -o pipefail -c
.DELETE_ON_ERROR: .DELETE_ON_ERROR:
MAKEFLAGS += --warn-undefined-variables
MAKEFLAGS += --no-builtin-rules
$(shell mkdir -p .build ../dist) $(shell mkdir -p .build ../dist)
OUTDIR := ../dist OUTDIR := ../dist
@ -50,10 +61,10 @@ DEPS := .build/tools .build/vernum ../meta/buildhash \
touch $@ touch $@
build: $(DEPS) build: $(DEPS)
rm -rf $(OUTDIR)/ankirspy* rm -rf "$(OUTDIR)"/ankirspy*
touch ../proto/backend.proto touch ../proto/backend.proto
FTL_TEMPLATE_DIRS="$(QT_FTL_TEMPLATES)" FTL_LOCALE_DIRS="$(QT_FTL_LOCALES)" \ FTL_TEMPLATE_DIRS="$(QT_FTL_TEMPLATES)" FTL_LOCALE_DIRS="$(QT_FTL_LOCALES)" \
maturin build -i $(shell which ${PYTHON_BIN}) -o $(OUTDIR) $(BUILDFLAGS) maturin build -i "${PYTHON_FILE}" -o "$(OUTDIR)" $(BUILDFLAGS)
check: .build/check check: .build/check

2
run
View file

@ -1,4 +1,6 @@
#!/bin/bash #!/bin/bash
set -eu -o pipefail ${SHELLFLAGS}
python --version python --version
make -C $(dirname $0) run RUNFLAGS="$*" make -C $(dirname $0) run RUNFLAGS="$*"