-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
126 lines (96 loc) · 3.19 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
SHELL := /bin/bash
DOCROOT := codepoints.net/
DEBUG := 1
PHP := php
PHP_ALL := $(shell find $(DOCROOT) -type f -not -path \*/vendor/\* -name \*.php)
JS_ALL := $(shell find src/js -type f -name \*.\?s)
XGETTEXT := bin/xgettext
COMPOSER := composer
COMPOSER_ARGS := --no-dev
ifeq ($(DEBUG), 1)
COMPOSER_ARGS :=
endif
all: css sw fonts views
.PHONY: all
css: vite-build
.PHONY: css
vite-build:
@npm run build
.PHONY: vite-build
fonts: src/fonts/Literata.woff2 src/fonts/Literata-Italic.woff2
.PHONY: fonts
src/fonts/Literata.woff2 src/fonts/Literata-Italic.woff2: src/fonts/%.woff2: src/fonts/%.ttf
pyftsubset "$<" \
--layout-features='*' \
--flavor=woff2 \
--unicodes='U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD, U+2714, U+2718' \
--output-file="$@"
sw: codepoints.net/sw.js
.PHONY: sw
codepoints.net/sw.js: workbox-config.js codepoints.net/static/*/*
rm -f codepoints.net/workbox-*.js
./node_modules/.bin/workbox generateSW workbox-config.js
views: codepoints.net/views/api.html
.PHONY: views
codepoints.net/views/api.html: openapi.yml
./node_modules/.bin/redoc-cli bundle "$<"
mv redoc-static.html "$@"
test: test-php test-js test-codeception
.PHONY: test
test-php: test-phpcs test-php-psalm
.PHONY: test-php
test-phpcs:
@./codepoints.net/vendor/bin/phpcs
.PHONY: test-phpcs
test-php-psalm:
@./codepoints.net/vendor/bin/psalm --show-info=true --php-version=8.3
.PHONY: test-php-psalm
test-js:
@npx eslint src/js/
.PHONY: test-js
test-codeception:
@docker compose run --rm codeception run
.PHONY: test-codeception
vendor: $(DOCROOT)vendor/autoload.php
$(DOCROOT)vendor/autoload.php: composer.lock
$(COMPOSER) install $(COMPOSER_ARGS)
@touch $@
composer.lock: composer.json
@touch $@
clear-cache:
@./codepoints.net/vendor/bin/psalm --clear-cache
@-rm -fr tests/_output/*
@# TODO if we implement response caching, clear that here, too
.PHONY: clear-cache
shell:
-@cd codepoints.net && php -d auto_prepend_file=init.php -a
.PHONY: shell
serve:
-@php -S localhost:8000 -t codepoints.net bin/devrouter.php
.PHONY: serve
po: $(DOCROOT)locale/messages.pot $(DOCROOT)locale/js.pot
.PHONY: po
$(DOCROOT)locale/messages.pot: $(PHP_ALL)
$(info * Compile PHP translation strings)
@$(XGETTEXT) -LPHP --from-code UTF-8 -k__ -k_q -k_f -kgettext -o $@ $(PHP_ALL)
$(DOCROOT)locale/js.pot: $(JS_ALL)
$(info * Compile JS translation strings)
@$(XGETTEXT) --version | sed -n 1p | grep -qE ' 0\.([3-9][0-9]|2[1-9])' || { \
echo 'xgettext v0.21 or higher needed!'; false; }
@$(XGETTEXT) -LJavaScript --from-code UTF-8 -k__ -kgettext -o $@ $^
mo:
$(info * Compile po to mo)
@find codepoints.net/locale -type f -name '*.po' -print0 | \
while IFS= read -r -d '' po; do \
msgfmt "$$po" -o "$${po/.po/.mo}"; \
done
@mkdir -p codepoints.net/static/locale
@find codepoints.net/locale -type f -name 'js.po' -print0 | \
while IFS= read -r -d '' po; do \
./node_modules/.bin/po2json --format mf "$$po" "src/public/locale/$$(basename $$(dirname $$(dirname "$$po"))).json"; \
done
.PHONY: mo
check:
cd ops/playbook && \
ansible-playbook --check --diff --inventory ./inventory ./playbook.yml
.PHONY: check