[HarfBuzz] harfbuzz: Branch 'master' - 5 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Tue Oct 30 07:52:29 UTC 2018


 .circleci/config.yml       |    2 +-
 CMakeLists.txt             |   19 ++++++-------------
 src/hb-ot-layout-common.hh |    1 +
 test/shaping/run-tests.py  |   32 ++++++++++++--------------------
 util/hb-shape.cc           |   30 ++++++++++++++++++++++++++++++
 util/options.cc            |    6 ++++++
 util/options.hh            |    8 ++++++--
 7 files changed, 62 insertions(+), 36 deletions(-)

New commits:
commit 422debb830fe150c26e1628f77531f41f0871325
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 30 00:51:43 2018 -0700

    [test/shaping] Spawn one hb-shape per test file
    
    Speeds up runnings in-house tests from over 20s to 2s.

diff --git a/test/shaping/run-tests.py b/test/shaping/run-tests.py
index f77a17c3..99c0a59f 100755
--- a/test/shaping/run-tests.py
+++ b/test/shaping/run-tests.py
@@ -2,16 +2,13 @@
 
 from __future__ import print_function, division, absolute_import
 
-import sys, os, subprocess, tempfile
-
+import sys, os, subprocess
 
 def cmd(command):
-	# https://stackoverflow.com/a/4408409
-	with tempfile.TemporaryFile() as tempf:
-		p = subprocess.Popen (command, stdout=tempf, stderr=sys.stdout)
-		p.wait ()
-		tempf.seek(0)
-		return tempf.read().decode ("utf-8").strip (), p.returncode
+	global process
+	process.stdin.write (' '.join (command) + '\n')
+	process.stdin.flush ()
+	return process.stdout.readline().decode ("utf-8").strip ()
 
 args = sys.argv[1:]
 if not args or sys.argv[1].find('hb-shape') == -1 or not os.path.exists (sys.argv[1]):
@@ -19,6 +16,11 @@ if not args or sys.argv[1].find('hb-shape') == -1 or not os.path.exists (sys.arg
 	sys.exit (1)
 hb_shape, args = args[0], args[1:]
 
+process = subprocess.Popen ([hb_shape, '--batch'],
+			    stdin=subprocess.PIPE,
+			    stdout=subprocess.PIPE,
+			    stderr=sys.stdout)
+
 fails = 0
 
 reference = False
@@ -60,24 +62,14 @@ for filename in args:
 			print ("%s %s %s %s --unicodes %s" %
 					 (hb_shape, fontfile, ' '.join(extra_options), options, unicodes))
 
-		glyphs1, returncode = cmd ([hb_shape, "--font-funcs=ft",
+		glyphs1 = cmd ([hb_shape, "--font-funcs=ft",
 			fontfile] + extra_options + ["--unicodes",
 			unicodes] + (options.split (' ') if options else []))
 
-		if returncode:
-			print ("ERROR: hb-shape --font-funcs=ft failed.") # file=sys.stderr
-			fails = fails + 1
-			#continue
-
-		glyphs2, returncode = cmd ([hb_shape, "--font-funcs=ot",
+		glyphs2 = cmd ([hb_shape, "--font-funcs=ot",
 			fontfile] + extra_options + ["--unicodes",
 			unicodes] + (options.split (' ') if options else []))
 
-		if returncode:
-			print ("ERROR: hb-shape --font-funcs=ot failed.") # file=sys.stderr
-			fails = fails + 1
-			#continue
-
 		if glyphs1 != glyphs2 and glyphs_expected != '*':
 			print ("FT funcs: " + glyphs1) # file=sys.stderr
 			print ("OT funcs: " + glyphs2) # file=sys.stderr
commit 58e20f53bf61244e3eef09be8ebed60aaf52fb11
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 30 00:50:18 2018 -0700

    [util] Add hb-shape --batch

diff --git a/util/hb-shape.cc b/util/hb-shape.cc
index 337cd431..6c727d01 100644
--- a/util/hb-shape.cc
+++ b/util/hb-shape.cc
@@ -160,6 +160,36 @@ struct output_buffer_t
 int
 main (int argc, char **argv)
 {
+  if (argc == 2 && !strcmp (argv[1], "--batch"))
+  {
+    unsigned int ret = 0;
+    char *buf = nullptr;
+    size_t len;
+    while (getline (&buf, &len, stdin) > 0)
+    {
+      size_t l = strlen (buf);
+      if (l && buf[l - 1] == '\n') buf[l - 1] = '\0';
+      main_font_text_t<shape_consumer_t<output_buffer_t>, FONT_SIZE_UPEM, 0> driver;
+      char *args[32];
+      argc = 0;
+      char *p = buf, *e;
+      args[argc++] = p;
+      while ((e = strchr (p, ' ')) && argc < (int) (int) ARRAY_LENGTH (args))
+      {
+	*e++ = '\0';
+	while (*e == ' ')
+	  e++;
+	args[argc++] = p = e;
+      }
+      ret |= driver.main (argc, args);
+      fflush (stdout);
+
+      if (ret)
+        break;
+    }
+    free (buf);
+    return ret;
+  }
   main_font_text_t<shape_consumer_t<output_buffer_t>, FONT_SIZE_UPEM, 0> driver;
   return driver.main (argc, argv);
 }
commit 6131fb6283cff87333db14b9b32e92be6139c3d6
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Tue Oct 30 00:38:01 2018 -0700

    [util] Don't close stdin/stdout

diff --git a/util/options.cc b/util/options.cc
index 5661cd05..4815770f 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -758,7 +758,10 @@ text_options_t::get_line (unsigned int *len)
       fail (true, "At least one of text or text-file must be set");
 
     if (0 != strcmp (text_file, "-"))
+    {
       fp = fopen (text_file, "r");
+      close_fp = true;
+    }
     else
       fp = stdin;
 
@@ -795,7 +798,10 @@ output_options_t::get_file_handle (void)
     return fp;
 
   if (output_file)
+  {
     fp = fopen (output_file, "wb");
+    close_fp = true;
+  }
   else {
 #if defined(_WIN32) || defined(__CYGWIN__)
     setmode (fileno (stdout), O_BINARY);
diff --git a/util/options.hh b/util/options.hh
index dd628590..6f35ea3f 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -510,6 +510,7 @@ struct text_options_t : option_group_t
     text_file = nullptr;
 
     fp = nullptr;
+    close_fp = false;
     gs = nullptr;
     line = nullptr;
     line_len = (unsigned int) -1;
@@ -524,7 +525,7 @@ struct text_options_t : option_group_t
     g_free (text_file);
     if (gs)
       g_string_free (gs, true);
-    if (fp)
+    if (close_fp)
       fclose (fp);
   }
 
@@ -547,6 +548,7 @@ struct text_options_t : option_group_t
 
   private:
   FILE *fp;
+  bool close_fp;
   GString *gs;
   char *line;
   unsigned int line_len;
@@ -563,6 +565,7 @@ struct output_options_t : option_group_t
     explicit_output_format = false;
 
     fp = nullptr;
+    close_fp = false;
 
     add_options (parser);
   }
@@ -570,7 +573,7 @@ struct output_options_t : option_group_t
   {
     g_free (output_file);
     g_free (output_format);
-    if (fp)
+    if (close_fp)
       fclose (fp);
   }
 
@@ -602,6 +605,7 @@ struct output_options_t : option_group_t
   bool explicit_output_format;
 
   mutable FILE *fp;
+  bool close_fp;
 };
 
 struct format_options_t : option_group_t
commit 7e998d193a1429b42bb69582f9e5738aa6fd1a72
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Oct 29 23:31:42 2018 -0700

    Fix spurious warning re uninitialized use

diff --git a/src/hb-ot-layout-common.hh b/src/hb-ot-layout-common.hh
index 47731053..3505b9cd 100644
--- a/src/hb-ot-layout-common.hh
+++ b/src/hb-ot-layout-common.hh
@@ -1110,6 +1110,7 @@ struct Coverage
   {
     inline Iter (const Coverage &c_)
     {
+      memset (this, 0, sizeof (*this));
       format = c_.u.format;
       switch (format)
       {
commit 1b7bfb5e1864fc355715b536faac6693b5ce0218
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Tue Oct 30 10:19:40 2018 +0330

    [cmake] Make build of tests and subset optional (#1329)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 46fb65b2..8ed1c394 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -37,7 +37,7 @@ jobs:
       # not needed to be a framework but we like to test that also
       # TODO: wrong way of targeting iOS as it doesn't point to iOS headers thus building
       # CoreText support is not possible, after the fix feel free HB_IOS from CMake altogether
-      - run: cmake -DBUILD_FRAMEWORK=ON -H. -Bbuild -GXcode -DHB_IOS=ON
+      - run: cmake -DBUILD_FRAMEWORK=ON -H. -Bbuild -GXcode -DHB_HAVE_CORETEXT=OFF -DHB_BUILD_SUBSET=OFF -DHB_BUILD_TESTS=OFF
       - run: cd build && xcodebuild -sdk iphoneos12.0 -configuration Release build -arch arm64
 
   distcheck:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4eb23af4..019e205b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,9 @@ if (HB_BUILD_UTILS)
   set (HB_HAVE_FREETYPE ON)
 endif ()
 
+option(HB_BUILD_SUBSET "Build harfbuzz-subset" ON)
+option(HB_BUILD_TESTS "Build harfbuzz tests" ON)
+
 option(HB_HAVE_GOBJECT "Enable GObject Bindings" OFF)
 if (HB_HAVE_GOBJECT)
   set (HB_HAVE_GLIB ON)
@@ -82,16 +85,6 @@ if (HB_CHECK)
   endif ()
 endif ()
 
-set (HB_DISABLE_SUBSET OFF)
-set (HB_DISABLE_TESTS OFF)
-option(HB_IOS "Apply iOS specific build flags" OFF)
-if (HB_IOS)
-  # We should fix their issue and enable them
-  set (HB_DISABLE_SUBSET ON)
-  set (HB_DISABLE_TESTS ON)
-  set (HB_HAVE_CORETEXT OFF)
-endif ()
-
 include_directories(AFTER
   ${PROJECT_SOURCE_DIR}/src
   ${PROJECT_BINARY_DIR}/src
@@ -556,7 +549,7 @@ add_library(harfbuzz ${project_sources} ${project_extra_sources} ${project_heade
 target_link_libraries(harfbuzz ${THIRD_PARTY_LIBS})
 
 ## Define harfbuzz-subset library
-if (NOT HB_DISABLE_SUBSET)
+if (HB_BUILD_SUBSET)
   add_library(harfbuzz-subset ${subset_project_sources} ${subset_project_headers})
   add_dependencies(harfbuzz-subset harfbuzz)
   target_link_libraries(harfbuzz-subset harfbuzz ${THIRD_PARTY_LIBS})
@@ -580,7 +573,7 @@ if (UNIX OR MINGW)
     set (CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "m") # libm
     set (CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "")
     set_target_properties(harfbuzz PROPERTIES LINKER_LANGUAGE C)
-    if (NOT HB_DISABLE_SUBSET)
+    if (HB_BUILD_SUBSET)
       set_target_properties(harfbuzz-subset PROPERTIES LINKER_LANGUAGE C)
     endif ()
 
@@ -861,7 +854,7 @@ if (UNIX AND CMAKE_GENERATOR STREQUAL "Ninja")
 endif ()
 
 
-if (NOT HB_DISABLE_TESTS)
+if (HB_BUILD_TESTS)
   ## src/ executables
   foreach (prog main test test-would-substitute test-size-params test-buffer-serialize hb-ot-tag test-unicode-ranges)
     set (prog_name ${prog})


More information about the HarfBuzz mailing list