plugin.video.viervijfzes/Makefile

98 lines
3.5 KiB
Makefile
Raw Permalink Normal View History

2020-07-09 10:16:45 +02:00
export KODI_HOME := $(CURDIR)/tests/home
export KODI_INTERACTIVE := 0
PYTHON := python
2020-03-19 16:45:31 +01:00
# Collect information to build as sensible package name
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)
2020-11-12 14:38:10 +01:00
ifdef release
zip_name = $(name)-$(version).zip
else
2021-02-23 18:29:57 +01:00
git_branch = $(shell git rev-parse --abbrev-ref HEAD)
git_hash = $(shell git rev-parse --short HEAD)
2020-11-12 14:38:10 +01:00
zip_name = $(name)-$(version)-$(git_branch)-$(git_hash).zip
endif
2020-03-19 16:45:31 +01:00
all: check test build
zip: build
2021-02-23 18:29:57 +01:00
multizip: build-all
2020-03-19 16:45:31 +01:00
2021-02-08 22:23:35 +01:00
check: check-pylint check-translations
2020-03-19 16:45:31 +01:00
check-pylint:
@printf ">>> Running pylint checks\n"
@$(PYTHON) -m pylint *.py resources/lib/ tests/
2020-03-19 16:45:31 +01:00
check-translations:
@printf ">>> Running translation checks\n"
2021-02-23 18:29:57 +01:00
@$(foreach lang,$(filter-out en_gb, $(patsubst resources/language/resource.language.%, %, $(wildcard resources/language/*))), \
msgcmp resources/language/resource.language.$(lang)/strings.po resources/language/resource.language.en_gb/strings.po; \
)
2020-04-20 16:09:00 +02:00
@tests/check_for_unused_translations.py
2020-03-19 16:45:31 +01:00
2021-02-23 18:29:57 +01:00
check-addon: check-addon-matrix
check-addon-leia:
@printf ">>> Running addon checks\n"
@make -s build-leia && cd dist/ && kodi-addon-checker --branch=leia
check-addon-matrix:
@printf ">>> Running addon checks\n"
2021-02-23 18:29:57 +01:00
@make -s build-matrix && cd dist/ && kodi-addon-checker --branch=matrix
2020-03-19 16:45:31 +01:00
codefix:
@isort -l 160 resources/
2020-03-19 16:45:31 +01:00
test: test-unit
test-unit:
@printf ">>> Running unit tests\n"
2020-11-28 17:13:21 +01:00
@$(PYTHON) -m pytest tests
2020-03-19 16:45:31 +01:00
clean:
@printf ">>> Cleaning up\n"
@find . -name '*.py[cod]' -type f -delete
2020-03-19 16:45:31 +01:00
@find . -name '__pycache__' -type d -delete
2021-02-08 22:23:35 +01:00
@rm -rf .pytest_cache/ tests/cdm tests/userdata/temp
2020-03-19 16:45:31 +01:00
@rm -f *.log .coverage
2021-02-23 18:29:57 +01:00
@rm -rf dist/
build: build-matrix
build-all: build-leia build-matrix
build-leia: clean
$(eval abi=2.26.0)
@rm -rf dist/ && mkdir dist/
@git archive --format tar --worktree-attributes --prefix $(name)/ $(or $(shell git stash create), HEAD) | (cd dist/ && tar -xf -)
@sed -i -E "s/(<!--)?(\s*<import addon=\"xbmc\.python\" version=\")[0-9\.]*(\"\/>)(\s*-->)?/\2$(abi)\3/" dist/$(name)/addon.xml
@cd dist && zip --quiet -9 -r ../../$(zip_name) $(name)
@printf ">>> Successfully wrote package for Kodi 18 as ../$(zip_name)\n"
build-matrix: clean
$(eval abi=3.0.0)
$(eval version=$(version)+matrix.1)
@rm -rf dist/ && mkdir dist/
@git archive --format tar --worktree-attributes --prefix $(name)/ $(or $(shell git stash create), HEAD) | (cd dist/ && tar -xf -)
@sed -i -E "s/(<!--)?(\s*<import addon=\"xbmc\.python\" version=\")[0-9\.]*(\"\/>)(\s*-->)?/\2$(abi)\3/" dist/$(name)/addon.xml
@printf "cd /addon/@version\nset $(version)\nsave\nbye\n" | xmllint --shell dist/$(name)/addon.xml > /dev/null
@cd dist && zip --quiet -9 -r ../../$(zip_name) $(name)
@printf ">>> Successfully wrote package for Kodi 19 as ../$(zip_name)\n"
2020-03-19 16:45:31 +01:00
2020-11-12 14:38:10 +01:00
# You first need to run sudo gem install github_changelog_generator for this
release:
ifneq ($(release),)
@github_changelog_generator -u add-ons -p $(name) --no-issues --exclude-labels duplicate,question,invalid,wontfix release --future-release v$(release);
2020-11-12 14:38:10 +01:00
@printf "cd /addon/@version\nset $$release\nsave\nbye\n" | xmllint --shell addon.xml; \
2020-11-12 14:38:10 +01:00
date=$(shell date '+%Y-%m-%d'); \
printf "cd /addon/extension[@point='xbmc.addon.metadata']/news\nset v$$release ($$date)\nsave\nbye\n" | xmllint --shell addon.xml; \
2020-11-12 14:38:10 +01:00
# Next steps to release:
# - Modify the news-section of addons.xml
# - git add . && git commit -m "Prepare for v$(release)" && git push
# - git tag v$(release) && git push --tags
else
@printf "Usage: make release release=1.0.0\n"
2020-11-12 14:38:10 +01:00
endif