2014-07-09 07:20:14 +00:00
|
|
|
# Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2014-07-10 04:04:19 +00:00
|
|
|
EMOJI = NotoColorEmoji
|
2014-08-13 02:28:00 +00:00
|
|
|
font: $(EMOJI).ttf
|
|
|
|
|
|
|
|
CFLAGS = -std=c99 -Wall -Wextra `pkg-config --cflags --libs cairo`
|
2016-10-07 21:17:09 +00:00
|
|
|
LDFLAGS = -lm `pkg-config --libs cairo`
|
2019-03-16 23:28:22 +00:00
|
|
|
|
|
|
|
PNGQUANT = pngquant
|
2019-10-21 14:58:06 +00:00
|
|
|
PYTHON = python3
|
2017-04-12 16:00:01 +00:00
|
|
|
PNGQUANTFLAGS = --speed 1 --skip-if-larger --quality 85-95 --force
|
2017-11-17 16:09:53 +00:00
|
|
|
BODY_DIMENSIONS = 136x128
|
|
|
|
IMOPS := -size $(BODY_DIMENSIONS) canvas:none -compose copy -gravity center
|
2014-09-18 02:31:16 +00:00
|
|
|
|
2015-11-14 01:35:50 +00:00
|
|
|
ZOPFLIPNG = zopflipng
|
2020-05-31 19:05:29 +00:00
|
|
|
TTX = ttx
|
2015-11-14 01:35:50 +00:00
|
|
|
|
|
|
|
EMOJI_BUILDER = third_party/color_emoji/emoji_builder.py
|
2018-05-09 22:41:08 +00:00
|
|
|
# flag for emoji builder. Default to legacy small metrics for the time being.
|
|
|
|
SMALL_METRICS := -S
|
2017-02-18 02:59:05 +00:00
|
|
|
ADD_GLYPHS = add_glyphs.py
|
|
|
|
ADD_GLYPHS_FLAGS = -a emoji_aliases.txt
|
2015-11-14 01:35:50 +00:00
|
|
|
PUA_ADDER = map_pua_emoji.py
|
|
|
|
VS_ADDER = add_vs_cmap.py # from nototools
|
|
|
|
|
2019-07-02 19:22:18 +00:00
|
|
|
EMOJI_SRC_DIR ?= png/128
|
2015-11-14 01:35:50 +00:00
|
|
|
FLAGS_SRC_DIR := third_party/region-flags/png
|
|
|
|
|
2020-05-06 07:19:25 +00:00
|
|
|
SEQUENCE_CHECK_PY = check_emoji_sequences.py
|
2020-04-22 07:45:14 +00:00
|
|
|
|
2015-11-14 01:35:50 +00:00
|
|
|
BUILD_DIR := build
|
|
|
|
EMOJI_DIR := $(BUILD_DIR)/emoji
|
|
|
|
FLAGS_DIR := $(BUILD_DIR)/flags
|
|
|
|
RESIZED_FLAGS_DIR := $(BUILD_DIR)/resized_flags
|
|
|
|
RENAMED_FLAGS_DIR := $(BUILD_DIR)/renamed_flags
|
|
|
|
QUANTIZED_DIR := $(BUILD_DIR)/quantized_pngs
|
|
|
|
COMPRESSED_DIR := $(BUILD_DIR)/compressed_pngs
|
2014-08-13 02:28:00 +00:00
|
|
|
|
2016-03-13 21:56:02 +00:00
|
|
|
# Unknown flag is PUA fe82b
|
2018-05-09 22:41:08 +00:00
|
|
|
# Note, we omit some flags below that we support via aliasing instead.
|
2016-03-13 21:56:02 +00:00
|
|
|
|
2014-08-14 19:02:14 +00:00
|
|
|
LIMITED_FLAGS = CN DE ES FR GB IT JP KR RU US
|
2016-03-12 03:02:15 +00:00
|
|
|
SELECTED_FLAGS = AC AD AE AF AG AI AL AM AO AQ AR AS AT AU AW AX AZ \
|
2019-07-02 19:22:18 +00:00
|
|
|
BA BB BD BE BF BG BH BI BJ BL BM BN BO BQ BR BS BT BW BY BZ \
|
2014-08-13 02:28:00 +00:00
|
|
|
CA CC CD CF CG CH CI CK CL CM CN CO CR CU CV CW CX CY CZ \
|
|
|
|
DE DJ DK DM DO DZ \
|
2018-05-09 22:41:08 +00:00
|
|
|
EC EE EG EH ER ES ET EU \
|
|
|
|
FI FJ FK FM FO FR \
|
|
|
|
GA GB GD GE GF GG GH GI GL GM GN GP GQ GR GS GT GU GW GY \
|
2014-08-13 02:28:00 +00:00
|
|
|
HK HN HR HT HU \
|
2016-03-12 03:02:15 +00:00
|
|
|
IC ID IE IL IM IN IO IQ IR IS IT \
|
2014-08-13 02:28:00 +00:00
|
|
|
JE JM JO JP \
|
|
|
|
KE KG KH KI KM KN KP KR KW KY KZ \
|
|
|
|
LA LB LC LI LK LR LS LT LU LV LY \
|
2019-07-02 19:22:18 +00:00
|
|
|
MA MC MD ME MG MH MK ML MM MN MO MP MQ MR MS MT MU MV MW MX MY MZ \
|
2018-05-09 22:41:08 +00:00
|
|
|
NA NC NE NF NG NI NL NO NP NR NU NZ \
|
2014-08-13 02:28:00 +00:00
|
|
|
OM \
|
2018-05-09 22:41:08 +00:00
|
|
|
PA PE PF PG PH PK PL PM PN PR PS PT PW PY \
|
2014-08-13 02:28:00 +00:00
|
|
|
QA \
|
2019-07-02 19:22:18 +00:00
|
|
|
RE RO RS RU RW \
|
2016-03-12 03:02:15 +00:00
|
|
|
SA SB SC SD SE SG SH SI SK SL SM SN SO SR SS ST SV SX SY SZ \
|
2019-07-02 19:22:18 +00:00
|
|
|
TA TC TD TF TG TH TJ TK TL TM TN TO TR TT TV TW TZ \
|
2017-01-24 22:27:29 +00:00
|
|
|
UA UG UN US UY UZ \
|
2014-08-13 02:28:00 +00:00
|
|
|
VA VC VE VG VI VN VU \
|
2018-05-09 22:41:08 +00:00
|
|
|
WF WS \
|
|
|
|
XK \
|
|
|
|
YE YT \
|
2017-01-26 00:57:37 +00:00
|
|
|
ZA ZM ZW \
|
|
|
|
GB-ENG GB-SCT GB-WLS
|
|
|
|
|
2020-05-31 19:05:29 +00:00
|
|
|
ifeq (,$(shell which $(ZOPFLIPNG)))
|
|
|
|
ifeq (,$(wildcard $(ZOPFLIPNG)))
|
|
|
|
MISSING_ZOPFLI = fail
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifndef VIRTUAL_ENV
|
|
|
|
MISSING_VENV = fail
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq (, $(shell which $(VS_ADDER)))
|
|
|
|
MISSING_PY_TOOLS = fail
|
|
|
|
endif
|
|
|
|
ifeq (, $(shell which $(TTX)))
|
|
|
|
MISSING_PY_TOOLS = fail
|
|
|
|
endif
|
|
|
|
|
2015-11-14 02:15:09 +00:00
|
|
|
ALL_FLAGS = $(basename $(notdir $(wildcard $(FLAGS_SRC_DIR)/*.png)))
|
2014-08-13 02:28:00 +00:00
|
|
|
|
2015-11-14 01:35:50 +00:00
|
|
|
FLAGS = $(SELECTED_FLAGS)
|
2014-08-13 02:28:00 +00:00
|
|
|
|
2015-11-14 01:35:50 +00:00
|
|
|
FLAG_NAMES = $(FLAGS:%=%.png)
|
|
|
|
FLAG_FILES = $(addprefix $(FLAGS_DIR)/, $(FLAG_NAMES))
|
|
|
|
RESIZED_FLAG_FILES = $(addprefix $(RESIZED_FLAGS_DIR)/, $(FLAG_NAMES))
|
2014-08-13 02:28:00 +00:00
|
|
|
|
2020-05-31 19:05:29 +00:00
|
|
|
ifndef MISSING_PY_TOOLS
|
2019-10-21 14:58:06 +00:00
|
|
|
FLAG_GLYPH_NAMES = $(shell $(PYTHON) flag_glyph_name.py $(FLAGS))
|
2020-05-31 19:05:29 +00:00
|
|
|
else
|
|
|
|
FLAG_GLYPH_NAMES =
|
|
|
|
endif
|
2015-11-14 01:35:50 +00:00
|
|
|
RENAMED_FLAG_NAMES = $(FLAG_GLYPH_NAMES:%=emoji_%.png)
|
|
|
|
RENAMED_FLAG_FILES = $(addprefix $(RENAMED_FLAGS_DIR)/, $(RENAMED_FLAG_NAMES))
|
|
|
|
|
|
|
|
EMOJI_NAMES = $(notdir $(wildcard $(EMOJI_SRC_DIR)/emoji_u*.png))
|
|
|
|
EMOJI_FILES= $(addprefix $(EMOJI_DIR)/,$(EMOJI_NAMES)))
|
|
|
|
|
|
|
|
ALL_NAMES = $(EMOJI_NAMES) $(RENAMED_FLAG_NAMES)
|
|
|
|
|
|
|
|
ALL_QUANTIZED_FILES = $(addprefix $(QUANTIZED_DIR)/, $(ALL_NAMES))
|
|
|
|
ALL_COMPRESSED_FILES = $(addprefix $(COMPRESSED_DIR)/, $(ALL_NAMES))
|
|
|
|
|
2014-07-09 07:20:14 +00:00
|
|
|
|
2015-11-14 01:35:50 +00:00
|
|
|
emoji: $(EMOJI_FILES)
|
|
|
|
|
|
|
|
flags: $(FLAG_FILES)
|
|
|
|
|
|
|
|
resized_flags: $(RESIZED_FLAG_FILES)
|
2015-11-05 19:15:15 +00:00
|
|
|
|
2015-11-14 01:35:50 +00:00
|
|
|
renamed_flags: $(RENAMED_FLAG_FILES)
|
|
|
|
|
|
|
|
quantized: $(ALL_QUANTIZED_FILES)
|
|
|
|
|
|
|
|
compressed: $(ALL_COMPRESSED_FILES)
|
|
|
|
|
2020-05-31 19:05:29 +00:00
|
|
|
check_tools:
|
2015-11-14 01:35:50 +00:00
|
|
|
ifdef MISSING_ZOPFLI
|
2020-05-30 21:51:53 +00:00
|
|
|
$(error "Missing $(ZOPFLIPNG). Try 'brew install zopfli' (Mac) or 'sudo apt-get install zopfli' (linux)")
|
2015-11-14 01:35:50 +00:00
|
|
|
endif
|
2020-05-31 19:05:29 +00:00
|
|
|
ifdef MISSING_VENV
|
|
|
|
$(error "Please start your virtual environment, and run: "'pip install -r requirements.txt'")
|
|
|
|
endif
|
|
|
|
ifdef MISSING_PY_TOOLS
|
|
|
|
$(error "Missing tools; run: "'pip install -r requirements.txt' in your virtual environment")
|
2015-11-14 01:35:50 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
$(EMOJI_DIR) $(FLAGS_DIR) $(RESIZED_FLAGS_DIR) $(RENAMED_FLAGS_DIR) $(QUANTIZED_DIR) $(COMPRESSED_DIR):
|
|
|
|
mkdir -p "$@"
|
|
|
|
|
|
|
|
|
|
|
|
waveflag: waveflag.c
|
|
|
|
$(CC) $< -o $@ $(CFLAGS) $(LDFLAGS)
|
|
|
|
|
2017-04-12 15:53:18 +00:00
|
|
|
|
|
|
|
# imagemagick's -extent operator munges the grayscale images in such a fashion
|
|
|
|
# that while it can display them correctly using libpng12, chrome and gimp using
|
|
|
|
# both libpng12 and libpng16 display the wrong gray levels.
|
|
|
|
#
|
|
|
|
# @convert "$<" -gravity center -background none -extent 136x128 "$@"
|
|
|
|
#
|
|
|
|
# We can get around the conversion to a gray colorspace in the version of
|
|
|
|
# imagemagick packaged with ubuntu trusty (6.7.7-10) by using -composite.
|
|
|
|
|
2015-11-14 01:35:50 +00:00
|
|
|
$(EMOJI_DIR)/%.png: $(EMOJI_SRC_DIR)/%.png | $(EMOJI_DIR)
|
2017-04-12 15:53:18 +00:00
|
|
|
@convert $(IMOPS) "$<" -composite "PNG32:$@"
|
2015-11-14 01:35:50 +00:00
|
|
|
|
2019-03-16 23:28:22 +00:00
|
|
|
$(FLAGS_DIR)/%.png: $(FLAGS_SRC_DIR)/%.png ./waveflag | $(FLAGS_DIR)
|
2016-10-07 21:22:30 +00:00
|
|
|
@./waveflag $(FLAGS_DIR)/ "$<"
|
2015-11-14 01:35:50 +00:00
|
|
|
|
|
|
|
$(RESIZED_FLAGS_DIR)/%.png: $(FLAGS_DIR)/%.png | $(RESIZED_FLAGS_DIR)
|
2017-04-12 15:53:18 +00:00
|
|
|
@convert $(IMOPS) "$<" -composite "PNG32:$@"
|
2015-11-14 01:35:50 +00:00
|
|
|
|
|
|
|
flag-symlinks: $(RESIZED_FLAG_FILES) | $(RENAMED_FLAGS_DIR)
|
2017-02-11 01:57:24 +00:00
|
|
|
@$(subst ^, , \
|
2015-11-14 01:35:50 +00:00
|
|
|
$(join \
|
|
|
|
$(FLAGS:%=ln^-fs^../resized_flags/%.png^), \
|
|
|
|
$(RENAMED_FLAG_FILES:%=%; ) \
|
|
|
|
) \
|
|
|
|
)
|
|
|
|
|
2015-12-01 01:49:52 +00:00
|
|
|
$(RENAMED_FLAG_FILES): | flag-symlinks
|
2015-11-14 01:35:50 +00:00
|
|
|
|
2019-03-16 23:28:22 +00:00
|
|
|
$(QUANTIZED_DIR)/%.png: $(RENAMED_FLAGS_DIR)/%.png | $(QUANTIZED_DIR)
|
2017-04-12 16:00:01 +00:00
|
|
|
@($(PNGQUANT) $(PNGQUANTFLAGS) -o "$@" "$<"; case "$$?" in "98"|"99") echo "reuse $<"; cp $< $@;; *) exit "$$?";; esac)
|
2015-11-14 01:35:50 +00:00
|
|
|
|
2019-03-16 23:28:22 +00:00
|
|
|
$(QUANTIZED_DIR)/%.png: $(EMOJI_DIR)/%.png | $(QUANTIZED_DIR)
|
2017-04-12 16:00:01 +00:00
|
|
|
@($(PNGQUANT) $(PNGQUANTFLAGS) -o "$@" "$<"; case "$$?" in "98"|"99") echo "reuse $<";cp $< $@;; *) exit "$$?";; esac)
|
2015-11-14 01:35:50 +00:00
|
|
|
|
2020-05-31 19:05:29 +00:00
|
|
|
$(COMPRESSED_DIR)/%.png: $(QUANTIZED_DIR)/%.png | check_tools $(COMPRESSED_DIR)
|
2017-04-12 15:59:16 +00:00
|
|
|
@$(ZOPFLIPNG) -y "$<" "$@" 1> /dev/null 2>&1
|
2015-11-14 01:35:50 +00:00
|
|
|
|
2015-12-01 01:49:52 +00:00
|
|
|
# Make 3.81 can endless loop here if the target is missing but no
|
|
|
|
# prerequisite is updated and make has been invoked with -j, e.g.:
|
|
|
|
# File `font' does not exist.
|
|
|
|
# File `NotoColorEmoji.tmpl.ttx' does not exist.
|
|
|
|
# File `font' does not exist.
|
|
|
|
# File `NotoColorEmoji.tmpl.ttx' does not exist.
|
|
|
|
# ...
|
|
|
|
# Run make without -j if this happens.
|
|
|
|
|
2015-11-14 01:35:50 +00:00
|
|
|
%.ttx: %.ttx.tmpl $(ADD_GLYPHS) $(ALL_COMPRESSED_FILES)
|
2019-10-21 14:58:06 +00:00
|
|
|
@$(PYTHON) $(ADD_GLYPHS) -f "$<" -o "$@" -d "$(COMPRESSED_DIR)" $(ADD_GLYPHS_FLAGS)
|
2015-11-05 19:15:15 +00:00
|
|
|
|
2014-07-09 07:20:14 +00:00
|
|
|
%.ttf: %.ttx
|
|
|
|
@rm -f "$@"
|
|
|
|
ttx "$<"
|
|
|
|
|
2020-05-06 08:09:58 +00:00
|
|
|
$(EMOJI).ttf: check_sequence $(EMOJI).tmpl.ttf $(EMOJI_BUILDER) $(PUA_ADDER) \
|
2020-05-31 19:07:55 +00:00
|
|
|
$(ALL_COMPRESSED_FILES) | check_tools
|
2020-06-16 06:22:41 +00:00
|
|
|
|
2020-08-10 12:25:13 +00:00
|
|
|
@$(PYTHON) $(EMOJI_BUILDER) $(SMALL_METRICS) -V $(word 2,$^) "$@" "$(COMPRESSED_DIR)/emoji_u"
|
2019-10-21 14:58:06 +00:00
|
|
|
@$(PYTHON) $(PUA_ADDER) "$@" "$@-with-pua"
|
2017-04-12 15:59:16 +00:00
|
|
|
@$(VS_ADDER) -vs 2640 2642 2695 --dstdir '.' -o "$@-with-pua-varsel" "$@-with-pua"
|
|
|
|
@mv "$@-with-pua-varsel" "$@"
|
|
|
|
@rm "$@-with-pua"
|
2014-07-09 07:20:14 +00:00
|
|
|
|
2020-05-06 08:09:58 +00:00
|
|
|
check_sequence:
|
2020-05-06 10:03:09 +00:00
|
|
|
ifdef BYPASS_SEQUENCE_CHECK
|
|
|
|
@echo Bypassing the emoji sequence checks
|
|
|
|
else
|
2020-08-07 12:43:53 +00:00
|
|
|
@$(PYTHON) $(SEQUENCE_CHECK_PY) -n $(ALL_NAMES) -c
|
2020-04-22 07:45:14 +00:00
|
|
|
endif
|
|
|
|
|
2014-07-09 07:20:14 +00:00
|
|
|
clean:
|
2014-07-10 04:04:19 +00:00
|
|
|
rm -f $(EMOJI).ttf $(EMOJI).tmpl.ttf $(EMOJI).tmpl.ttx
|
2014-08-13 02:28:00 +00:00
|
|
|
rm -f waveflag
|
2015-11-14 01:35:50 +00:00
|
|
|
rm -rf $(BUILD_DIR)
|
|
|
|
|
|
|
|
.SECONDARY: $(EMOJI_FILES) $(FLAG_FILES) $(RESIZED_FLAG_FILES) $(RENAMED_FLAG_FILES) \
|
2017-02-11 01:57:24 +00:00
|
|
|
$(ALL_QUANTIZED_FILES) $(ALL_COMPRESSED_FILES)
|
2015-11-14 01:35:50 +00:00
|
|
|
|
2020-05-31 19:05:29 +00:00
|
|
|
.PHONY: clean flags emoji renamed_flags quantized compressed check_tools
|
2015-11-14 01:35:50 +00:00
|
|
|
|