forked from add-ons/plugin.video.vrt.nu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (75 loc) · 3.14 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
export PYTHONPATH := $(CURDIR)/resources/lib:$(CURDIR)/tests
PYTHON := python
KODI_PYTHON_ABIS := 2.25.0 3.0.0
name = $(shell xmllint --xpath 'string(/addon/@id)' addon.xml)
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)
matrix = $(findstring $(shell xmllint --xpath 'string(/addon/requires/import[@addon="xbmc.python"]/@version)' addon.xml), $(word 1,$(KODI_PYTHON_ABIS)))
ifdef release
zip_name = $(name)-$(version).zip
else
zip_name = $(name)-$(version)-$(git_branch)-$(git_hash).zip
endif
zip_dir = $(name)/
languages = $(filter-out en_gb, $(patsubst resources/language/resource.language.%, %, $(wildcard resources/language/*)))
path := /
blue = \e[1;34m
white = \e[1;37m
reset = \e[0;39m
all: check test build
zip: build
test: check test-unit test-service test-run
check: check-tox check-pylint check-translations
check-tox:
@printf "$(white)=$(blue) Starting sanity tox test$(reset)\n"
$(PYTHON) -m tox -q
check-pylint:
@printf "$(white)=$(blue) Starting sanity pylint test$(reset)\n"
$(PYTHON) -m pylint resources/lib/ tests/
check-translations:
@printf "$(white)=$(blue) Starting language test$(reset)\n"
@-$(foreach lang,$(languages), \
msgcmp resources/language/resource.language.$(lang)/strings.po resources/language/resource.language.en_gb/strings.po; \
)
check-addon: clean
@printf "$(white)=$(blue) Starting sanity addon tests$(reset)\n"
kodi-addon-checker . --branch=krypton
kodi-addon-checker . --branch=leia
kill-proxy:
-pkill -ef '$(PYTHON) -m proxy'
unit: test-unit
run: test-run
test-unit: clean kill-proxy
@printf "$(white)=$(blue) Starting unit tests$(reset)\n"
-$(PYTHON) -m proxy --hostname 127.0.0.1 --log-level DEBUG &
$(PYTHON) -m unittest discover -v
-pkill -ef '$(PYTHON) -m proxy'
test-service:
@printf "$(white)=$(blue) Run service$(reset)\n"
$(PYTHON) resources/lib/service_entry.py
test-run:
@printf "$(white)=$(blue) Run CLI$(reset)\n"
$(PYTHON) tests/run.py $(path)
profile:
@printf "$(white)=$(blue) Profiling $(white)$(path)$(reset)\n"
$(PYTHON) -m cProfile -o profiling_stats-$(git_branch)-$(git_hash).bin tests/run.py $(path)
build: clean
@printf "$(white)=$(blue) Building new package$(reset)\n"
@rm -f ../$(zip_name)
@git archive --format zip --worktree-attributes -v -o ../$(zip_name) --prefix $(zip_dir) $(or $(shell git stash create), HEAD)
@printf "$(white)=$(blue) Successfully wrote package as: $(white)../$(zip_name)$(reset)\n"
multizip: clean
@-$(foreach abi,$(KODI_PYTHON_ABIS), \
printf "cd /addon/requires/import[@addon='xbmc.python']/@version\nset $(abi)\nsave\nbye\n" | xmllint --shell addon.xml; \
leia=$(findstring $(abi), $(word 1,$(KODI_PYTHON_ABIS))); \
if [ $$leia ]; then version=$(patsubst %+matrix.1,%,$(version)); else version=$(version); fi; \
printf "cd /addon/@version\nset $$version\nsave\nbye\n" | xmllint --shell addon.xml; \
make build; \
)
clean:
@printf "$(white)=$(blue) Cleaning up$(reset)\n"
find . -name '*.py[cod]' -type f -delete
find . -name '__pycache__' -type d -delete
rm -rf .pytest_cache/ .tox/
rm -f *.log tests/userdata/tokens/*.tkn