-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
150 lines (122 loc) · 4.55 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
name = RealEmoji
version = 0.1.0
author = Jakub Valenta
url = https://real-emoji.ooooo.page
license = Creative Commons Attribution 4.0 International
license_url = http://creativecommons.org/licenses/by/4.0/
_python_pkg = emoji
curr_dir = $(shell pwd)
twemoji_color_font_dir = $(curr_dir)/twemoji-color-font
build_dir = $(curr_dir)/build/$(name)
src_dir = svg
svg_dir = $(build_dir)/svg
svg_twemoji = $(twemoji_color_font_dir)/assets/twemoji-svg
svg_extra_bw = $(twemoji_color_font_dir)/assets/svg-bw
emojis_json = emojis.json
web_svg_dir = static/svg
web_png_dir = static/png
dist_dir = $(curr_dir)/static/fonts
ttf_font = $(dist_dir)/$(name).ttf
mac_font = $(dist_dir)/$(name)-OSX-$(version).zip
web_fonts = $(dist_dir)/$(name).eot $(dist_dir)/$(name).woff $(dist_dir)/$(name).svg
web_font_woff2 = $(dist_dir)/$(name).woff2
web_data_dir = data/$(name)
web_data_file = $(web_data_dir)/emojis.json
web_assets_dir = assets
web_posts_dir = content/emoji
web_npm_installed = $(web_assets_dir)/node_modules/normalize.css/normalize.css
web_deps = $(web_svg_dir) $(web_png_dir) $(web_data_file) $(web_fonts) $(web_font_woff2) $(web_npm_installed) $(web_posts_dir)
.PHONY: font clean clean-font-only serve try clean-try setup setup-dev lint reformat help
font: $(ttf_font) $(mac_font) ## Build the TTF file and the macOS font package
$(dist_dir):
mkdir -p "$@"
$(svg_dir): $(_python_pkg)/copy.py $(emojis_json) $(src_dir)
mkdir -p "$@"
python3 -m emoji.copy -s "$(src_dir)" -d "$@" < $(emojis_json)
$(web_svg_dir): $(svg_dir)
rm -r "$(web_svg_dir)" || true
mkdir -p "$(web_svg_dir)"
cp -a "$(src_dir)"/*.svg "$(web_svg_dir)"
rm "$(web_svg_dir)"/*-src.svg
for f in "$(web_svg_dir)"/*.svg; do svgo -i "$$f"; done
$(web_png_dir): $(web_svg_dir)
rm -r "$@" || true
mkdir -p "$@"
for path_in in "$<"/*.svg; do \
path_in_basename=$$(basename "$$path_in"); \
path_out="$@/$${path_in_basename%.*}.png"; \
inkscape -z -e "$$path_out" -w 512 -h 512 "$$path_in"; \
optipng -preserve "$$path_out"; \
done
$(web_png_dir)/_telegram.png: $(web_svg_dir)/violence.svg
inkscape -z -e "$@" -w 100 -h 100 "$<"
optipng -preserve "$@"
$(ttf_font): | $(svg_dir) $(dist_dir)
cd $(twemoji_color_font_dir) && \
$(MAKE) all \
BUILD_DIR="$(build_dir)" \
VERSION="$(version)" \
FONT_PREFIX="$(name)" \
SVG_TWEMOJI="$(svg_twemoji)" \
SVG_EXTRA_BW="$(svg_extra_bw)" \
SVG_EXTRA="$(svg_dir)"
cp -a "$(build_dir)/$(name).ttf" "$@"
$(mac_font): | $(svg_dir) $(dist_dir)
cd $(twemoji_color_font_dir) && \
$(MAKE) osx-package \
BUILD_DIR="$(build_dir)" \
VERSION="$(version)" \
FONT_PREFIX="$(name)" \
SVG_TWEMOJI="$(svg_twemoji)" \
SVG_EXTRA_BW="$(svg_extra_bw)" \
SVG_EXTRA="$(svg_dir)"
cp -a "$(build_dir)/$(name)-OSX-$(version).zip" "$@"
$(web_posts_dir):
mkdir -p "$@"
python3 -m emoji.posts -d "$(web_posts_dir)" < $(emojis_json)
clean: ## Remove the built TTF file, webfonts, and intermediate SVG files
-rm -r "$(build_dir)" || true
-rm -f $(dist_dir)/$(name)*.ttf
-rm -f $(dist_dir)/$(name)*.zip
clean-font-only: ## Remove the built TTF files and macOS font packages
-rm -f $(build_dir)/$(name)*.ttf
-rm -f $(build_dir)/$(name)*.zip
$(web_fonts): $(ttf_font)
webify "$<"
$(web_font_woff2): $(ttf_font)
woff2_compress "$<"
$(web_npm_installed):
cd "$(web_assets_dir)" && npm install
$(web_data_dir):
mkdir -p "$@"
$(web_data_file): $(_python_pkg)/build.py $(emojis_json) | $(web_data_dir)
python3 -m emoji.build < $(emojis_json) > $(web_data_file)
build: $(web_deps) ## Build website
hugo
serve: $(web_deps) ## Serve website
hugo server
build/RealEmojiTry/emojis.json: $(_python_pkg)/try.py emojis.json
mkdir -p build/RealEmojiTry
python3 -m emoji.try < emojis.json > "$@"
try: build/RealEmojiTry/emojis.json ## Render sequence testing page
$(MAKE) serve \
name="RealEmojiTry" \
emojis_json="build/RealEmojiTry/emojis.json"
clean-try: ## Clean sequence testing files
-rm -r build/RealEmojiTry/svg
-rm -f build/RealEmojiTry/*.ttf
-rm build/RealEmojiTry/emojis.json
setup: ## Create Pipenv virtual environment and install dependencies.
pipenv --three --site-packages
pipenv install
bundler install --path vendor/bundle
setup-dev: ## Install development dependencies
pipenv install --dev
lint: ## Run linting
pipenv run flake8 $(_python_pkg)
pipenv run mypy $(_python_pkg) --ignore-missing-imports
pipenv run isort -c -rc $(_python_pkg)
reformat: ## Reformat Python code using Black
black -l 79 --skip-string-normalization $(_python_pkg)
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}'