Extensions: refactor CommandBatch.exec_non_blocking return value
[blender-addons-contrib.git] / bl_pkg / Makefile
blob0551dd44f9c2f584e4d9750d52a8da162344d039
1 # SPDX-FileCopyrightText: 2011-2023 Blender Authors
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # note: this isn't needed for building,
6 # its just for some convenience targets.
8 # Needed for when tests are run from another directory: `make -C ./path/to/this/directory`
9 BASE_DIR := ${CURDIR}
11 PY_FILES=$(shell find ./ -type f -name '*.py')
12 # Filter out files which use `bpy`.
13 PY_FILES_MYPY=$(filter-out \
14 ./__init__.py \
15 ./bl_extension_cli.py \
16 ./bl_extension_local.py \
17 ./bl_extension_monkeypatch.py \
18 ./bl_extension_notify.py \
19 ./bl_extension_ops.py \
20 ./bl_extension_ui.py \
21 ./bl_extension_utils.py \
22 ./wheel_manager.py \
23 ./example_extension/__init__.py \
24 ./example_extension/foo.py \
25 ,$(PY_FILES))
27 PY_FILES_MYPY_STANDALONE= \
28 ./bl_extension_utils.py \
29 ./bl_extension_cli.py \
30 ./wheel_manager.py
32 EXTRA_WATCH_FILES=Makefile
34 # For tests that launch Blender directly.
35 BLENDER_BIN?=$(shell which blender)
36 PYTHON_BIN?=$(shell which python3)
38 pep8: FORCE
39 @flake8 $(PY_FILES) --ignore=E501,E302,E123,E126,E128,E129,E124,E122,W504
41 # `--no-namespace-packages` is needed otherwise `./cli/blender_ext.py` loads in parent modules
42 # (the Blender add-on which imports `bpy`).
43 check_mypy: FORCE
44 @mypy --no-namespace-packages --strict $(PY_FILES_MYPY)
45 @mypy --strict --follow-imports=skip $(PY_FILES_MYPY_STANDALONE)
47 check_ruff: FORCE
48 @env --chdir="$(BASE_DIR)" ruff check $(PY_FILES_MYPY)
49 @env --chdir="$(BASE_DIR)" ruff check $(PY_FILES_MYPY_STANDALONE)
51 check_pylint:
52 @env --chdir="$(BASE_DIR)" \
53 pylint $(PY_FILES) \
54 --disable=C0111,C0301,C0302,C0103,C0415,R1705,R0902,R0903,R0913,E0611,E0401,I1101,R0801,C0209,W0511,W0718,W0719,C0413,R0911,R0912,R0914,R0915
56 # python3 ./tests/test_cli.py
57 test: FORCE
58 @env --chdir="$(BASE_DIR)" \
59 USE_HTTP=0 \
60 $(PYTHON_BIN) ./tests/test_cli.py
61 @env --chdir="$(BASE_DIR)" \
62 USE_HTTP=1 \
63 $(PYTHON_BIN) ./tests/test_cli.py
65 # NOTE: these rely on the blender binary.
66 test_blender: FORCE
67 @env --chdir="$(BASE_DIR)" \
68 ASAN_OPTIONS=check_initialization_order=0:leak_check_at_exit=0 \
69 $(BLENDER_BIN) --background --factory-startup -noaudio --python ./tests/test_blender.py -- --verbose
71 watch_test_blender: FORCE
72 @cd "$(BASE_DIR)" && \
73 while true; do \
74 $(MAKE) test_blender; \
75 inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
76 tput clear; \
77 done
79 test_cli_blender: FORCE
80 @env BLENDER_BIN=$(BLENDER_BIN) \
81 $(PYTHON_BIN) ./tests/test_cli_blender.py
83 watch_test_cli_blender: FORCE
84 @while true; do \
85 env BLENDER_BIN=$(BLENDER_BIN) \
86 $(MAKE) test_cli_blender; \
87 inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
88 tput clear; \
89 done
92 # https://www.cyberciti.biz/faq/howto-create-linux-ram-disk-filesystem/
93 # mkfs -q /dev/ram1 8192
94 # mkdir -p /ramcache
95 # sudo mount /dev/ram1 /ramcache
96 # sudo chmod 777 /ramcache
97 # mkdir /ramcache/tmp
99 watch_test: FORCE
100 @cd "$(BASE_DIR)" && \
101 while true; do \
102 $(MAKE) test; \
103 inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
104 tput clear; \
105 done
107 watch_check_mypy:
108 @cd "$(BASE_DIR)" && \
109 while true; do \
110 $(MAKE) check_mypy; \
111 inotifywait -q -e close_write $(EXTRA_WATCH_FILES) \
112 $(PY_FILES_MYPY) \
113 ./bl_extension_utils.py ; \
114 tput clear; \
115 done
117 watch_check_ruff:
118 @cd "$(BASE_DIR)" && \
119 while true; do \
120 $(MAKE) check_ruff; \
121 inotifywait -q -e close_write $(EXTRA_WATCH_FILES) \
122 $(PY_FILES_MYPY) \
123 ./bl_extension_utils.py ; \
124 tput clear; \
125 done
127 watch_check_pylint:
128 @cd "$(BASE_DIR)" && \
129 while true; do \
130 $(MAKE) check_pylint; \
131 inotifywait -q -e close_write $(EXTRA_WATCH_FILES) $(PY_FILES) ; \
132 tput clear; \
133 done
136 FORCE: