[pango/use-hb-fallback-only-when-needed] build: Only use fallback dependency for HarfBuzz when needed



commit 95c645f521654d21c409be1786bcc3d25a56e56e
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Mon Jul 15 11:42:52 2019 +0800

    build: Only use fallback dependency for HarfBuzz when needed
    
    Unfortunately the CMake dependency discovery mechanism is broken in
    Meson, so on MSVC builds we still look first for the HarfBuzz headers
    and .lib's, and ensure that they are 2.0.0 or later, before we try to
    use the fallback dependency.
    
    We do, however, want to make use of the fallback if HarfBuzz cannot be
    found since HarfBuzz is now a hard dependency of Pango for all builds.

 meson.build | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
---
diff --git a/meson.build b/meson.build
index 73b5da2b..13d9bbff 100644
--- a/meson.build
+++ b/meson.build
@@ -229,23 +229,32 @@ harfbuzz_pc=''
 freetype2_pc=''
 fontconfig_pc=''
 harfbuzz_lib=''
-freetype2_lib=''
 fontconfig_lib=''
 
-harfbuzz_dep = dependency('harfbuzz', version: harfbuzz_req_version, required: false,
-                          fallback: ['harfbuzz', 'libharfbuzz_dep'])
+harfbuzz_dep = dependency('harfbuzz', version: harfbuzz_req_version, required: false)
 if harfbuzz_dep.found()
   harfbuzz_pc = 'harfbuzz'
 else
   if cc.get_id() == 'msvc' and cc.has_header('hb.h')
     # The CMake build files for HarfBuzz (which is used for MSVC builds) do not
-    # generate pkg-config files, so look for harfbuzz.lib
-    harfbuzz_dep = cc.find_library('harfbuzz', required: false)
-    if harfbuzz_dep.found()
-      harfbuzz_lib = '-lharfbuzz'
+    # generate pkg-config files, so look for harfbuzz.lib.  Ensure that we
+    # we look for HarfBuzz 2.0.0 or later.
+    harfbuzz_lib = cc.find_library('harfbuzz', required: false)
+    if harfbuzz_lib.found()
+      if cc.has_function('hb_ot_tags_from_script_and_language', dependencies: harfbuzz_lib)
+        harfbuzz_dep = harfbuzz_lib
+      endif
     endif
   endif
 endif
+
+# Remove when Meson acquires ability to declare deps declaratively, or
+# when finding dependencies via CMake files is fixed.
+if not harfbuzz_dep.found()
+  harfbuzz_dep = dependency('harfbuzz', version: harfbuzz_req_version,
+                            fallback: ['harfbuzz', 'libharfbuzz_dep'])
+endif
+
 if harfbuzz_dep.found()
   pango_deps += harfbuzz_dep
 endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]