-
-
Notifications
You must be signed in to change notification settings - Fork 68
/
Makefile
389 lines (314 loc) · 10.9 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
DESTDIR = ./distrib
PREFIX = /usr
APPDIR = /opt/oomox
DEST_APPDIR = $(DESTDIR)$(APPDIR)
DEST_PLUGIN_DIR = $(DESTDIR)$(APPDIR)/plugins
DEST_PREFIX = $(DESTDIR)$(PREFIX)
SHELL := bash
PYTHON := $(shell which python3)
ifeq (,$(PYTHON))
$(error Can't find `python3`)
endif
# lint:
RUFF := ruff
script_dir := $(shell readlink -e .)
APP_DIR := $(shell readlink -e "$(script_dir)")
TARGET_MODULE := oomox_gui
TARGETS := $(APP_DIR)/oomox_gui/ $(shell ls $(APP_DIR)/plugins/*/oomox_plugin.py) $(shell ls $(APP_DIR)/maintenance_scripts/*.py)
GLOBALS_IGNORES := \
-e ': Final' \
-e ' \# nonfinal-ignore' \
-e ' \# checkglobals-ignore' \
\
-e TypeVar \
-e namedtuple \
-e Generic \
-e Sequence \
\
-e 'BaseClass' \
-e 'HexColor' \
-e 'ColorScheme' \
\
-e './maintenance_scripts/find_.*.py.*:.*:' \
-e '.SRCINFO'
################################################################################
.PHONY: all
all: install
################################################################################
install_gui: install_import_random
$(eval PACKAGING_TMP_DIR := $(shell mktemp -d))
mkdir -p $(DEST_APPDIR)
cp -prf \
CREDITS \
LICENSE \
README.md \
scripted_colors \
colors \
gui.sh \
oomox_gui \
po \
po.mk \
terminal_templates \
export_config_examples \
$(DEST_APPDIR)/
cp -prf \
packaging/ \
$(PACKAGING_TMP_DIR)/
sed -i -e 's|/opt/oomox/|$(APPDIR)/|g' $(PACKAGING_TMP_DIR)/packaging/bin/*
chmod a+x "$(PACKAGING_TMP_DIR)/packaging/bin/"*
install -Dp -m 755 "$(PACKAGING_TMP_DIR)/packaging/bin/oomox-gui" -t "$(DEST_PREFIX)/bin/"
install -Dp -m 755 "$(PACKAGING_TMP_DIR)/packaging/bin/themix-gui" -t "$(DEST_PREFIX)/bin/"
install -Dp -m 755 "$(PACKAGING_TMP_DIR)/packaging/bin/themix-multi-export" -t "$(DEST_PREFIX)/bin/"
install -Dp -m 644 "$(PACKAGING_TMP_DIR)/packaging/com.github.themix_project.Oomox.desktop" -t "$(DEST_PREFIX)/share/applications/"
install -Dp -m 644 "$(PACKAGING_TMP_DIR)/packaging/com.github.themix_project.Oomox.appdata.xml" -t "$(DEST_PREFIX)/share/metainfo/"
install -Dp -m 644 "$(PACKAGING_TMP_DIR)/packaging/com.github.themix_project.Oomox-symbolic.svg" -t "$(DEST_PREFIX)/share/icons/hicolor/symbolic/apps/com.github.themix_project.Oomox-symbolic.svg"
install -Dp -m 644 "$(PACKAGING_TMP_DIR)/packaging/com.github.themix_project.Oomox.svg" -t "$(DEST_PREFIX)/share/icons/hicolor/scalable/apps/com.github.themix_project.Oomox.svg"
$(RM) -r $(PACKAGING_TMP_DIR)
# will update ./po and produce ./locale dir:
make -C $(DEST_APPDIR) -f po.mk install
rm $(DEST_APPDIR)/po.mk
install_theme_arc:
$(eval PLUGIN_NAME := theme_arc)
mkdir -p $(DEST_PLUGIN_DIR)
cp -prf \
plugins/$(PLUGIN_NAME) \
$(DEST_PLUGIN_DIR)/
$(RM) -r "$(DEST_PLUGIN_DIR)/$(PLUGIN_NAME)"/*/.git*
install_theme_oomox:
$(eval PLUGIN_NAME := theme_oomox)
make -C plugins/$(PLUGIN_NAME) -f Makefile_oomox_plugin DESTDIR=$(DESTDIR) APPDIR=$(APPDIR) PREFIX=$(PREFIX) install
install_theme_materia:
$(eval PLUGIN_NAME := theme_materia)
$(eval CLI_NAME := oomox-materia-cli)
$(eval PACKAGING_TMP_DIR := $(shell mktemp -d))
cp -prf \
packaging/ \
$(PACKAGING_TMP_DIR)/
sed -i -e 's|/opt/oomox/|$(APPDIR)/|g' $(PACKAGING_TMP_DIR)/packaging/bin/*
chmod a+x "$(PACKAGING_TMP_DIR)/packaging/bin/"*
install -d $(DEST_PREFIX)/bin/
install -Dp -m 755 "$(PACKAGING_TMP_DIR)/packaging/bin/$(CLI_NAME)" "$(DEST_PREFIX)/bin/"
mkdir -p $(DEST_PLUGIN_DIR)
cp -prf \
plugins/$(PLUGIN_NAME) \
$(DEST_PLUGIN_DIR)/
$(RM) -r "$(DEST_PLUGIN_DIR)/$(PLUGIN_NAME)"/*/.git*
install_export_oomoxify:
$(eval PLUGIN_NAME := export_oomoxify)
make -C plugins/$(PLUGIN_NAME) -f Makefile_oomox_plugin DESTDIR=$(DESTDIR) APPDIR=$(APPDIR) PREFIX=$(PREFIX) install
install_import_random:
$(eval PLUGIN_NAME := import_random)
mkdir -p $(DEST_PLUGIN_DIR)
cp -prf \
plugins/$(PLUGIN_NAME) \
$(DEST_PLUGIN_DIR)/
install_import_xresources:
$(eval PLUGIN_NAME := import_xresources)
mkdir -p $(DEST_PLUGIN_DIR)
cp -prf \
plugins/$(PLUGIN_NAME) \
$(DEST_PLUGIN_DIR)/
install_export_xresources:
$(eval PLUGIN_NAME := export_xresources)
mkdir -p $(DEST_PLUGIN_DIR)
cp -prf \
plugins/$(PLUGIN_NAME) \
$(DEST_PLUGIN_DIR)/
install_import_images:
$(eval PLUGIN_NAME := import_from_image)
mkdir -p $(DEST_PLUGIN_DIR)
cp -prf \
plugins/$(PLUGIN_NAME) \
$(DEST_PLUGIN_DIR)/
install_plugin_base16:
$(eval PLUGIN_NAME := base16)
make -C plugins/$(PLUGIN_NAME) -f Makefile_oomox_plugin DESTDIR=$(DESTDIR) APPDIR=$(APPDIR) PREFIX=$(PREFIX) install
install_icons_archdroid:
$(eval PLUGIN_NAME := icons_archdroid)
$(eval CLI_NAME := oomox-archdroid-icons-cli)
$(eval PACKAGING_TMP_DIR := $(shell mktemp -d))
cp -prf \
packaging/ \
$(PACKAGING_TMP_DIR)/
sed -i -e 's|/opt/oomox/|$(APPDIR)/|g' $(PACKAGING_TMP_DIR)/packaging/bin/*
chmod a+x "$(PACKAGING_TMP_DIR)/packaging/bin/"*
install -d $(DEST_PREFIX)/bin/
install -Dp -m 755 "$(PACKAGING_TMP_DIR)/packaging/bin/$(CLI_NAME)" "$(DEST_PREFIX)/bin/"
mkdir -p $(DEST_PLUGIN_DIR)
cp -prf \
plugins/$(PLUGIN_NAME) \
$(DEST_PLUGIN_DIR)/
$(RM) -r "$(DEST_PLUGIN_DIR)/$(PLUGIN_NAME)"/*/.git*
install_icons_gnomecolors:
$(eval PLUGIN_NAME := icons_gnomecolors)
$(eval CLI_NAME := oomox-gnome-colors-icons-cli)
$(eval PACKAGING_TMP_DIR := $(shell mktemp -d))
cp -prf \
packaging/ \
$(PACKAGING_TMP_DIR)/
sed -i -e 's|/opt/oomox/|$(APPDIR)/|g' $(PACKAGING_TMP_DIR)/packaging/bin/*
chmod a+x "$(PACKAGING_TMP_DIR)/packaging/bin/"*
install -d $(DEST_PREFIX)/bin/
install -Dp -m 755 "$(PACKAGING_TMP_DIR)/packaging/bin/$(CLI_NAME)" "$(DEST_PREFIX)/bin/"
mkdir -p $(DEST_PLUGIN_DIR)
cp -prf \
plugins/$(PLUGIN_NAME) \
$(DEST_PLUGIN_DIR)/
$(RM) -r "$(DEST_PLUGIN_DIR)/$(PLUGIN_NAME)"/*/.git*
install_icons_numix:
$(eval PLUGIN_NAME := icons_numix)
mkdir -p $(DEST_PLUGIN_DIR)
cp -prf \
plugins/$(PLUGIN_NAME) \
$(DEST_PLUGIN_DIR)/
$(RM) -r "$(DEST_PLUGIN_DIR)/$(PLUGIN_NAME)"/*/.git*
install_icons_papirus:
$(eval PLUGIN_NAME := icons_papirus)
mkdir -p $(DEST_PLUGIN_DIR)
cp -prf \
plugins/$(PLUGIN_NAME) \
$(DEST_PLUGIN_DIR)/
$(RM) -r "$(DEST_PLUGIN_DIR)/$(PLUGIN_NAME)"/*/.git*
install_icons_suruplus:
$(eval PLUGIN_NAME := icons_suruplus)
mkdir -p $(DEST_PLUGIN_DIR)
cp -prf \
plugins/$(PLUGIN_NAME) \
$(DEST_PLUGIN_DIR)/
$(RM) -r "$(DEST_PLUGIN_DIR)/$(PLUGIN_NAME)"/*/.git*
install_icons_suruplus_aspromauros:
$(eval PLUGIN_NAME := icons_suruplus_aspromauros)
mkdir -p $(DEST_PLUGIN_DIR)
cp -prf \
plugins/$(PLUGIN_NAME) \
$(DEST_PLUGIN_DIR)/
$(RM) -r "$(DEST_PLUGIN_DIR)/$(PLUGIN_NAME)"/*/.git*
.PHONY: install
.PHONY: install_gui install_import_random install_theme_arc install_theme_oomox install_theme_materia install_export_oomoxify install_import_images install_plugin_base16 install_icons_archdroid install_icons_gnomecolors install_icons_numix install_icons_papirus install_icons_suruplus install_icons_suruplus_aspromauros install_import_xresources install_export_xresources
install: install_gui install_theme_oomox install_theme_materia install_export_oomoxify install_import_images install_plugin_base16 install_icons_archdroid install_icons_gnomecolors install_icons_numix install_icons_papirus install_icons_suruplus install_icons_suruplus_aspromauros install_import_xresources install_export_xresources
################################################################################
lint_fix:
$(RUFF) check --fix $(TARGETS)
compile_all:
export PYTHONWARNINGS='ignore,error:::$(TARGET_MODULE)[.*],error:::pikaur_test[.*]'
# Running python compile:
$(PYTHON) -O -m compileall $(TARGETS) \
| (\
grep -v -e '^Listing' -e '^Compiling' || true \
)
# :: python compile passed ::
python_import:
# Running python import:
$(PYTHON) -c "import $(TARGET_MODULE).main"
# :: python import passed ::
non_final_globals:
# Checking for non-Final globals:
result=$$( \
grep -REn "^[a-zA-Z_]+ = " $(TARGETS) --color=always \
| grep -Ev \
\
-e '=.*\|' \
-e '=.*(dict|list|Callable)\[' \
\
$(GLOBALS_IGNORES) \
| sort \
) ; \
echo -n "$$result" ; \
exit "$$(test "$$result" = "" && echo 0 || echo 1)"
# :: non-final globals check passed ::
unreasonable_globals:
# Checking for unreasonable global vars:
result=$$( \
grep -REn "^[a-zA-Z_]+ = [^'\"].*" $(TARGETS) --color=always \
| grep -Ev \
\
-e ' =.*\|' \
-e ' = [a-zA-Z_]+\[' \
-e ' = str[^(]' \
\
$(GLOBALS_IGNORES) \
| sort \
) ; \
echo -n "$$result" ; \
exit "$$(test "$$result" = "" && echo 0 || echo 1)"
# :: global vars check passed ::
ruff:
# Checking Ruff rules up-to-date:
diff --color -u \
<(awk '/select = \[/,/]/' pyproject.toml \
| sed -e 's|", "|/|g' \
| head -n -1 \
| tail -n +2 \
| tr -d '",\#' \
| awk '{print $$1;}' \
| sort) \
<($(RUFF) linter \
| awk '{print $$1;}' \
| sort)
# Running ruff...
$(RUFF) check $(TARGETS)
# :: ruff passed ::
flake8:
# Running flake8:
$(PYTHON) -m flake8 $(TARGETS)
# :: flake8 passed ::
pylint:
# Running pylint:
$(PYTHON) -m pylint $(TARGETS) --score no
# :: pylint passed ::
mypy:
# Running mypy:
#$(PYTHON) -m mypy $(TARGETS) --no-error-summary
$(PYTHON) -m mypy $(TARGET_MODULE) --no-error-summary
# :: mypy passed ::
vulture:
# Running vulture:
$(PYTHON) -m vulture $(TARGETS) \
--min-confidence=1 \
--sort-by-size
# :: vulture passed ::
shellcheck:
# shellcheck disable=SC2046
# Running shellcheck:
( \
cd $(APP_DIR) || exit ; \
shellcheck $$(find . \
-name '*.sh' \
-not -path './plugins/icons_archdroid/archdroid-icon-theme/*' \
-not -path './plugins/icons_gnomecolors/gnome-colors-icon-theme/*' \
-not -path './plugins/icons_papirus/papirus-icon-theme/*' \
-not -path './plugins/icons_suruplus/suru-plus/*' \
-not -path './plugins/icons_suruplus_aspromauros/suru-plus-aspromauros/*' \
-not -path './plugins/base16/*.tmp/*' \
-not -path './plugins/oomoxify/*' \
-not -path './plugins/theme_arc/arc-theme/*' \
-not -path './plugins/theme_materia/materia-theme/*' \
-not -path './plugins/theme_oomox/gtk-theme/*' \
-or -path './packaging/bin/*' \
) \
)
# :: shellcheck passed ::
shellcheck_makefile:
# Running shellcheck on Makefile...
( \
cd $(APP_DIR) || exit ; \
$(PYTHON) ./maintenance_scripts/makefile_shellcheck.py \
--skip lint \
--skip lint_ubuntu_310 \
; \
)
# :: shellcheck makefile passed ::
validate_pyproject:
# Validate pyproject file...
( \
exit_code=0 ; \
result=$$(validate-pyproject pyproject.toml 2>&1) || exit_code=$$? ; \
if [[ $$exit_code -gt 0 ]] ; then \
echo "$$result" ; \
exit "$$exit_code" ; \
fi \
)
# :: pyproject validation passed ::
.PHONY: lint compile_all python_import non_final_globals unreasonable_globals ruff flake8 pylint mypy vulture shellcheck shellcheck_makefile validate_pyproject
lint: compile_all python_import non_final_globals unreasonable_globals ruff flake8 pylint mypy vulture shellcheck shellcheck_makefile validate_pyproject
lint_ubuntu_310: compile_all python_import non_final_globals unreasonable_globals flake8 pylint