2020-03-19 16:45:31 +01:00
|
|
|
export PYTHONPATH := $(CURDIR):$(CURDIR)/test
|
2020-03-25 08:08:15 +01:00
|
|
|
PYTHON := python
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
# Collect information to build as sensible package name
|
2020-03-25 08:08:15 +01:00
|
|
|
name = $(shell xmllint --xpath 'string(/addon/@id)' addon.xml)
|
2020-03-19 16:45:31 +01:00
|
|
|
version = $(shell xmllint --xpath 'string(/addon/@version)' addon.xml)
|
|
|
|
git_branch = $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
git_hash = $(shell git rev-parse --short HEAD)
|
|
|
|
zip_name = $(name)-$(version)-$(git_branch)-$(git_hash).zip
|
2020-03-25 08:08:15 +01:00
|
|
|
include_files = addon_entry.py addon.xml CHANGELOG.md LICENSE README.md resources/ service_entry.py
|
2020-03-19 16:45:31 +01:00
|
|
|
include_paths = $(patsubst %,$(name)/%,$(include_files))
|
|
|
|
exclude_files = \*.new \*.orig \*.pyc \*.pyo
|
|
|
|
|
2020-03-25 08:08:15 +01:00
|
|
|
languages = $(filter-out en_gb, $(patsubst resources/language/resource.language.%, %, $(wildcard resources/language/*)))
|
|
|
|
|
|
|
|
.PHONY: check test
|
|
|
|
|
2020-03-19 16:45:31 +01:00
|
|
|
all: check test build
|
|
|
|
zip: build
|
|
|
|
|
|
|
|
check: check-pylint check-tox check-translations
|
|
|
|
|
|
|
|
check-pylint:
|
|
|
|
@echo ">>> Running pylint checks"
|
2020-03-25 08:08:15 +01:00
|
|
|
@$(PYTHON) -m pylint *.py resources/lib/ test/
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
check-tox:
|
|
|
|
@echo ">>> Running tox checks"
|
2020-03-25 08:08:15 +01:00
|
|
|
@$(PYTHON) -m tox -q
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
check-translations:
|
|
|
|
@echo ">>> Running translation checks"
|
2020-03-25 08:08:15 +01:00
|
|
|
@$(foreach lang,$(languages), \
|
|
|
|
msgcmp resources/language/resource.language.$(lang)/strings.po resources/language/resource.language.en_gb/strings.po; \
|
|
|
|
)
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
check-addon: clean build
|
|
|
|
@echo ">>> Running addon checks"
|
|
|
|
$(eval TMPDIR := $(shell mktemp -d))
|
|
|
|
@unzip ../${zip_name} -d ${TMPDIR}
|
|
|
|
cd ${TMPDIR} && kodi-addon-checker --branch=leia
|
|
|
|
@rm -rf ${TMPDIR}
|
|
|
|
|
|
|
|
test: test-unit
|
|
|
|
|
|
|
|
test-unit:
|
|
|
|
@echo ">>> Running unit tests"
|
2020-03-26 11:31:28 +01:00
|
|
|
@$(PYTHON) -m unittest discover -v -b -f
|
2020-03-19 16:45:31 +01:00
|
|
|
|
|
|
|
clean:
|
|
|
|
@find . -name '*.pyc' -type f -delete
|
|
|
|
@find . -name '*.pyo' -type f -delete
|
|
|
|
@find . -name '__pycache__' -type d -delete
|
|
|
|
@rm -rf .pytest_cache/ .tox/ test/cdm test/userdata/temp
|
|
|
|
@rm -f *.log .coverage
|
|
|
|
|
|
|
|
build: clean
|
|
|
|
@echo ">>> Building package"
|
|
|
|
@rm -f ../$(zip_name)
|
|
|
|
cd ..; zip -r $(zip_name) $(include_paths) -x $(exclude_files)
|
|
|
|
@echo "Successfully wrote package as: ../$(zip_name)"
|
|
|
|
|
|
|
|
release: build
|
2020-03-25 08:08:15 +01:00
|
|
|
rm -rf ../repo-plugins/$(name)/*
|
2020-03-19 16:45:31 +01:00
|
|
|
unzip ../$(zip_name) -d ../repo-plugins/
|