[gtk/gtk-3-24-meson: 20/66] meson: Only use cairo fallbacks when needed



commit de1a4e7777199ad86cb2aab7be46bd03e776c7cc
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Wed Mar 13 12:13:22 2019 +0800

    meson: Only use cairo fallbacks when needed
    
    On Visual Studio builds, since Cairo builds tend not to generate
    pkg-config files for us, look for the headers and .lib's, before
    attempting to download the Cairo repo (which is quite large) and
    building it.
    
    We can simplify this process when Meson gains the ability to check
    for the dependencies in a declarative fashion, but before that, this
    is what must be done.

 meson.build | 47 ++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 40 insertions(+), 7 deletions(-)
---
diff --git a/meson.build b/meson.build
index f8b94f2548..ecfbc38d05 100644
--- a/meson.build
+++ b/meson.build
@@ -307,10 +307,35 @@ if os_unix
 endif
 gmodule_dep    = dependency('gmodule-2.0', version: glib_req,
                             fallback : ['glib', 'libgmodule_dep'])
-cairo_dep      = dependency('cairo', version: cairo_req,
-                            fallback : ['cairo', 'libcairo_dep'])
-cairogobj_dep  = dependency('cairo-gobject', version: cairo_req,
-                            fallback : ['cairo', 'libcairogobject_dep'])
+
+# Update when we can find depedencies in a declarative manner
+cairo_dep      = dependency('cairo', version: cairo_req, required: cc.get_id() != 'msvc')
+cairogobj_dep  = dependency('cairo-gobject', version: cairo_req, required: cc.get_id() != 'msvc')
+
+# Remove when we can find depedencies in a declarative manner
+if not cairo_dep.found() and cc.get_id() == 'msvc'
+  if cc.has_header('cairo.h') and cc.has_header('cairo-win32.h')
+    cairo_dep = cc.find_library('cairo', required: false)
+  endif
+endif
+
+if not cairo_dep.found()
+  cairo_dep      = dependency('cairo', version: cairo_req,
+                              fallback : ['cairo', 'libcairo_dep'])
+endif
+
+# Remove when we can find depedencies in a declarative manner
+if not cairogobj_dep.found() and cc.get_id() == 'msvc'
+  if cc.has_header('cairo-gobject.h')
+    cairogobj_dep = cc.find_library('cairo-gobject', required: false)
+  endif
+endif
+
+if not cairogobj_dep.found()
+  cairogobj_dep  = dependency('cairo-gobject', version: cairo_req,
+                              fallback : ['cairo', 'libcairogobject_dep'])
+endif
+
 pango_dep      = dependency('pango', version: pango_req,
                             fallback : ['pango', 'libpango_dep'])
 
@@ -370,6 +395,8 @@ if cairo_found_type == 'internal'
   cairo_features = subproject('cairo').get_variable('built_features')
 endif
 
+cairogobj_found_type = cairogobj_dep.type_name()
+
 cairo_backends = []
 foreach backend: [ ['cairo-xlib', cairo_req, x11_enabled],
                    ['cairo-win32', cairo_req, win32_enabled],
@@ -383,12 +410,14 @@ foreach backend: [ ['cairo-xlib', cairo_req, x11_enabled],
       if dependency(cairo_backend, version: cairo_backend_req, required : cc.get_id() != 'msvc').found()
         cairo_backends += cairo_backend
       endif
-    else
+    elif cairo_found_type == 'internal'
       foreach f: cairo_features
         if f['name'] == cairo_backend
           cairo_backends += cairo_backend
         endif
       endforeach
+    elif cc.get_id() == 'msvc' and cairo_dep.found()
+      cairo_backends += 'cairo-win32'
     endif
   endif
 endforeach
@@ -396,10 +425,10 @@ endforeach
 cairo_pkg_found = false
 cairogobj_pkg_found = false
 
-if cairo_dep.found()
+if cairo_found_type == 'internal' or cairo_found_type == 'pkgconfig'
   cairo_pkg_found = true
 endif
-if cairogobj_dep.found()
+if cairogobj_found_type == 'internal' or cairogobj_found_type == 'pkgconfig'
   cairogobj_pkg_found = true
 endif
 
@@ -613,9 +642,13 @@ gdk_packages = ' '.join([ pango_pkgname, pango_req,
 
 if cairo_pkg_found
   gdk_packages += ' '.join([ ' cairo', cairo_req ])
+elif cc.get_id() == 'msvc' and cairo_dep.found()
+  gdk_packages += ' '.join([ ' -lcairo' ])
 endif
 if cairogobj_pkg_found
   gdk_packages += ' '.join([ ' cairo-gobject', cairo_req ])
+elif cc.get_id() == 'msvc' and cairogobj_dep.found()
+  gdk_packages += ' '.join([ ' -lcairo-gobject' ])
 endif
 
 pkgconf.set('GDK_PACKAGES', gdk_packages)


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