From e58a66978a458b23da8d47857778414a0812b3ea Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 19 Jun 2015 18:34:08 +0200 Subject: [PATCH 1/5] Fix build Fix the paths after repo split. --- Makefile | 10 +++++----- add_svg_glyphs.py | 2 +- flag_glyph_name.py | 2 +- map_pua_emoji.py | 3 ++- third_party/color_emoji/add_glyphs.py | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 000933cc3..94dae55e1 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,7 @@ font: $(EMOJI).ttf CFLAGS = -std=c99 -Wall -Wextra `pkg-config --cflags --libs cairo` LDFLAGS = `pkg-config --libs cairo` -PNGQUANTDIR := $(abspath `pwd`/../../third_party/pngquant) +PNGQUANTDIR := $(abspath `pwd`/../third_party/pngquant) PNGQUANT := $(PNGQUANTDIR)/pngquant PNGQUANTFLAGS = --speed 1 --skip-if-larger --ext '.png' --force @@ -55,7 +55,7 @@ FLAGS = AD AE AF AG AI AL AM AO AR AS AT AU AW AX AZ \ YE \ ZA ZM ZW -FLAGS_SRC_DIR = ../third_party/region-flags/png +FLAGS_SRC_DIR = third_party/region-flags/png FLAGS_DIR = ./flags glyph_name = $(shell ./flag_glyph_name.py $(flag)) @@ -76,9 +76,9 @@ $(PNG128_FLAGS): flag-symlinks EMOJI_PNG128 = ./png/128/emoji_u -EMOJI_BUILDER = ../third_party/color_emoji/emoji_builder.py -ADD_GLYPHS = ../third_party/color_emoji/add_glyphs.py -PUA_ADDER = ../nototools/map_pua_emoji.py +EMOJI_BUILDER = third_party/color_emoji/emoji_builder.py +ADD_GLYPHS = third_party/color_emoji/add_glyphs.py +PUA_ADDER = map_pua_emoji.py %.ttx: %.ttx.tmpl $(ADD_GLYPHS) $(UNI) flag-symlinks python $(ADD_GLYPHS) "$<" "$@" "$(EMOJI_PNG128)" diff --git a/add_svg_glyphs.py b/add_svg_glyphs.py index 413f0d398..913bfd0cf 100755 --- a/add_svg_glyphs.py +++ b/add_svg_glyphs.py @@ -33,8 +33,8 @@ from fontTools.ttLib.tables import otTables from fontTools.ttLib.tables import _g_l_y_f from fontTools.ttLib.tables import S_V_G_ as SVG from fontTools import ttx -from nototools import add_emoji_gsub +import add_emoji_gsub import svg_builder import svg_cleaner diff --git a/flag_glyph_name.py b/flag_glyph_name.py index e51b56fb9..f5d6ce256 100755 --- a/flag_glyph_name.py +++ b/flag_glyph_name.py @@ -20,7 +20,7 @@ __author__ = 'roozbeh@google.com (Roozbeh Pournader)' import sys -from nototools import add_emoji_gsub +import add_emoji_gsub def two_letter_code_to_glyph_name(iso_code): return 'u%04x_%04x' % ( diff --git a/map_pua_emoji.py b/map_pua_emoji.py index 5d03b9df6..676aea39f 100644 --- a/map_pua_emoji.py +++ b/map_pua_emoji.py @@ -22,9 +22,10 @@ import sys from fontTools import ttLib -from nototools import add_emoji_gsub from nototools import font_data +import add_emoji_gsub + def get_glyph_name_from_gsub(char_seq, font): """Find the glyph name for ligature of a given character sequence from GSUB. diff --git a/third_party/color_emoji/add_glyphs.py b/third_party/color_emoji/add_glyphs.py index dc2b11c81..d92962458 100644 --- a/third_party/color_emoji/add_glyphs.py +++ b/third_party/color_emoji/add_glyphs.py @@ -5,8 +5,8 @@ from fontTools import ttx from fontTools.ttLib.tables import otTables from png import PNG -sys.path.append('../../nototools') -from nototools import add_emoji_gsub +sys.path.append('../../') +import add_emoji_gsub def glyph_name(string): From 0955c3cddcdfbeb7122d1e142fc2d986cdc4c2c6 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Fri, 19 Jun 2015 18:48:22 +0200 Subject: [PATCH 2/5] Python is not always installed as /usr/bin/python --- add_emoji_gsub.py | 2 +- add_svg_glyphs.py | 2 +- collect_emoji_svg.py | 2 +- flag_glyph_name.py | 2 +- generate_test_html.py | 2 +- map_pua_emoji.py | 2 +- svg_cleaner.py | 2 +- third_party/color_emoji/add_glyphs.py | 2 +- third_party/color_emoji/emoji_builder.py | 2 +- third_party/color_emoji/png.py | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/add_emoji_gsub.py b/add_emoji_gsub.py index b440e5fa5..bae73cbb4 100755 --- a/add_emoji_gsub.py +++ b/add_emoji_gsub.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # Copyright 2014 Google Inc. All rights reserved. # diff --git a/add_svg_glyphs.py b/add_svg_glyphs.py index 913bfd0cf..191b5ffad 100755 --- a/add_svg_glyphs.py +++ b/add_svg_glyphs.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright 2015 Google, Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/collect_emoji_svg.py b/collect_emoji_svg.py index fb56352be..bb0f744a8 100755 --- a/collect_emoji_svg.py +++ b/collect_emoji_svg.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright 2015 Google, Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/flag_glyph_name.py b/flag_glyph_name.py index f5d6ce256..f773fdfa3 100755 --- a/flag_glyph_name.py +++ b/flag_glyph_name.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # Copyright 2014 Google Inc. All rights reserved. # diff --git a/generate_test_html.py b/generate_test_html.py index 37c76e4e3..ed119ad90 100755 --- a/generate_test_html.py +++ b/generate_test_html.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright 2015 Google, Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/map_pua_emoji.py b/map_pua_emoji.py index 676aea39f..aac031c56 100644 --- a/map_pua_emoji.py +++ b/map_pua_emoji.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # Copyright 2014 Google Inc. All rights reserved. # diff --git a/svg_cleaner.py b/svg_cleaner.py index 6743d9715..be419046e 100755 --- a/svg_cleaner.py +++ b/svg_cleaner.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright 2015 Google, Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/third_party/color_emoji/add_glyphs.py b/third_party/color_emoji/add_glyphs.py index d92962458..1c1d1ce2e 100644 --- a/third_party/color_emoji/add_glyphs.py +++ b/third_party/color_emoji/add_glyphs.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python import glob, sys from fontTools import ttx diff --git a/third_party/color_emoji/emoji_builder.py b/third_party/color_emoji/emoji_builder.py index bc8e5dad7..5a4e646fe 100644 --- a/third_party/color_emoji/emoji_builder.py +++ b/third_party/color_emoji/emoji_builder.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # Copyright 2013 Google, Inc. All Rights Reserved. # diff --git a/third_party/color_emoji/png.py b/third_party/color_emoji/png.py index a56ad2355..20f849aef 100644 --- a/third_party/color_emoji/png.py +++ b/third_party/color_emoji/png.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # Copyright 2013 Google, Inc. All Rights Reserved. # From cee85f422b06577c9dbcce24f43618eb9e52b39f Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Sat, 20 Jun 2015 00:59:00 +0200 Subject: [PATCH 3/5] Speed up make by calling flag_glyph_name.py once This script takes ~1 second for startup, so calling it repeatedly for each flag slows the Makefile considerably, and unnecessarily since it can be called for all the flags at once. Now make clean takes about 1.2s, instead of 3m45s. --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 94dae55e1..3c110bd1c 100644 --- a/Makefile +++ b/Makefile @@ -60,8 +60,9 @@ FLAGS_DIR = ./flags glyph_name = $(shell ./flag_glyph_name.py $(flag)) +GLYPH_NAMES := $(shell ./flag_glyph_name.py $(FLAGS)) WAVED_FLAGS := $(foreach flag,$(FLAGS),$(FLAGS_DIR)/$(flag).png) -PNG128_FLAGS := $(foreach flag,$(FLAGS),$(addprefix ./png/128/emoji_$(glyph_name),.png)) +PNG128_FLAGS := $(foreach glyph_name,$(GLYPH_NAMES),$(addprefix ./png/128/emoji_$(glyph_name),.png)) $(FLAGS_DIR)/%.png: $(FLAGS_SRC_DIR)/%.png ./waveflag $(PNGQUANT) mkdir -p $(FLAGS_DIR) From b257b6647d6e4fe8dbcfaa36c9e67a74bb81bd5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C4=81vis?= Date: Wed, 24 Jun 2015 12:31:51 +0300 Subject: [PATCH 4/5] Quote $PNGQUANTDIR and $PNGQUANT Quoting is necessary so that can build from path which contains spaces --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 3c110bd1c..60a1b4b0a 100644 --- a/Makefile +++ b/Makefile @@ -22,8 +22,8 @@ PNGQUANTDIR := $(abspath `pwd`/../third_party/pngquant) PNGQUANT := $(PNGQUANTDIR)/pngquant PNGQUANTFLAGS = --speed 1 --skip-if-larger --ext '.png' --force -$(PNGQUANT): - cd $(PNGQUANTDIR) && make +"$(PNGQUANT)": + cd "$(PNGQUANTDIR)" && make waveflag: waveflag.c $(CC) $< -o $@ $(CFLAGS) $(LDFLAGS) @@ -64,11 +64,11 @@ GLYPH_NAMES := $(shell ./flag_glyph_name.py $(FLAGS)) WAVED_FLAGS := $(foreach flag,$(FLAGS),$(FLAGS_DIR)/$(flag).png) PNG128_FLAGS := $(foreach glyph_name,$(GLYPH_NAMES),$(addprefix ./png/128/emoji_$(glyph_name),.png)) -$(FLAGS_DIR)/%.png: $(FLAGS_SRC_DIR)/%.png ./waveflag $(PNGQUANT) +$(FLAGS_DIR)/%.png: $(FLAGS_SRC_DIR)/%.png ./waveflag "$(PNGQUANT)" mkdir -p $(FLAGS_DIR) ./waveflag "$<" "$@" optipng -quiet -o7 "$@" - $(PNGQUANT) $(PNGQUANTFLAGS) "$@" + "$(PNGQUANT)" $(PNGQUANTFLAGS) "$@" flag-symlinks: $(WAVED_FLAGS) $(foreach flag,$(FLAGS),ln -fs ../../flags/$(flag).png ./png/128/emoji_$(glyph_name).png;) From 1140041c2bcc7c5c9d7ec45438f83124cecda383 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Mon, 22 Jun 2015 03:32:08 +0200 Subject: [PATCH 5/5] Further speed up make Similar to cee85f422b06577c9dbcce24f43618eb9e52b39f. --- Makefile | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 60a1b4b0a..c71774a94 100644 --- a/Makefile +++ b/Makefile @@ -58,8 +58,6 @@ FLAGS = AD AE AF AG AI AL AM AO AR AS AT AU AW AX AZ \ FLAGS_SRC_DIR = third_party/region-flags/png FLAGS_DIR = ./flags -glyph_name = $(shell ./flag_glyph_name.py $(flag)) - GLYPH_NAMES := $(shell ./flag_glyph_name.py $(FLAGS)) WAVED_FLAGS := $(foreach flag,$(FLAGS),$(FLAGS_DIR)/$(flag).png) PNG128_FLAGS := $(foreach glyph_name,$(GLYPH_NAMES),$(addprefix ./png/128/emoji_$(glyph_name),.png)) @@ -71,7 +69,12 @@ $(FLAGS_DIR)/%.png: $(FLAGS_SRC_DIR)/%.png ./waveflag "$(PNGQUANT)" "$(PNGQUANT)" $(PNGQUANTFLAGS) "$@" flag-symlinks: $(WAVED_FLAGS) - $(foreach flag,$(FLAGS),ln -fs ../../flags/$(flag).png ./png/128/emoji_$(glyph_name).png;) + $(subst ^, , \ + $(join \ + $(FLAGS:%=ln^-fs^../../flags/%.png^), \ + $(GLYPH_NAMES:%=./png/128/emoji_%.png;) \ + ) \ + ) $(PNG128_FLAGS): flag-symlinks