[gobject-introspection/meson-tests-use-cairo] meson: build libregress with cairo support



commit ee6983081df75e479b7838e189cd310e3da57cc4
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Mon Dec 31 21:19:58 2018 +0100

    meson: build libregress with cairo support
    
    The cairo dependency fallback code is copied from pygobject. I assume that
    will work for msvc users (cairo is disabled by default anyway)

 .gitlab-ci/test-msys2-meson.sh |  2 +-
 meson.build                    | 14 ++++++++++++++
 tests/scanner/meson.build      | 32 +++++++++++++++++++++++++-------
 3 files changed, 40 insertions(+), 8 deletions(-)
---
diff --git a/.gitlab-ci/test-msys2-meson.sh b/.gitlab-ci/test-msys2-meson.sh
index da4c3eaf..e2230e2a 100644
--- a/.gitlab-ci/test-msys2-meson.sh
+++ b/.gitlab-ci/test-msys2-meson.sh
@@ -37,7 +37,7 @@ export PATH="$HOME/.local/bin:$PATH"
 # FIXME: https://github.com/Alexpux/MINGW-packages/pull/4064
 # Passing the full interpreter path works around the issue
 PYTHON="$(which python3)"
-meson -Dpython="${PYTHON}" --buildtype debug _build
+meson -Dcairo=true -Dpython="${PYTHON}" --buildtype debug _build
 cd _build
 ninja
 
diff --git a/meson.build b/meson.build
index 79c76302..025f5180 100644
--- a/meson.build
+++ b/meson.build
@@ -139,6 +139,20 @@ endif
 libffi_dep = dependency('libffi',
   fallback : ['libffi', 'ffi_dep'])
 
+with_cairo = get_option('cairo')
+
+if with_cairo
+  cairo_dep = dependency('cairo', required: cc.get_id() != 'msvc')
+  cairo_gobject_dep = dependency('cairo-gobject', required: cc.get_id() != 'msvc')
+
+  if cc.get_id() == 'msvc' and (not cairo_gobject_dep.found() or not cairo_dep.found())
+    if cc.has_header('cairo.h') and cc.has_header ('cairo-gobject.h')
+      cairo_dep = cc.find_library ('cairo')
+      cairo_gobject_dep = cc.find_library ('cairo-gobject')
+    endif
+  endif
+endif
+
 subdir('girepository')
 subdir('tools')
 subdir('giscanner')
diff --git a/tests/scanner/meson.build b/tests/scanner/meson.build
index c63570b4..541a1862 100644
--- a/tests/scanner/meson.build
+++ b/tests/scanner/meson.build
@@ -71,13 +71,20 @@ custom_c_args = cc.get_supported_arguments([
   '-Wno-old-style-definition',
   '-Wno-missing-field-initializers',
 ])
-# FIXME: build with cairo
-custom_c_args += ['-D_GI_DISABLE_CAIRO']
+
+if with_cairo
+  regress_deps = [cairo_dep, cairo_gobject_dep]
+  regress_c_args = []
+else
+  regress_deps = []
+  regress_c_args += ['-D_GI_DISABLE_CAIRO']
+endif
+
 regress_lib = shared_library('regress-1.0',
   sources: ['regress.c', 'annotation.c', 'foo.c', 'drawable.c'],
   include_directories : [configinc, include_directories('..')],
-  c_args: gi_hidden_visibility_cflags + custom_c_args,
-  dependencies: [gobject_dep, gio_dep],
+  c_args: gi_hidden_visibility_cflags + regress_c_args + custom_c_args,
+  dependencies: [gobject_dep, gio_dep] + regress_deps,
 )
 
 if glib_dep.type_name() == 'pkgconfig'
@@ -244,8 +251,13 @@ if glib_dep.type_name() == 'pkgconfig'
     ]
   )
 
-  # FIXME: build with cairo and add to 'test_girs'
-  custom_target('gir-regress',
+  if with_cairo
+    regress_scanner_cairo_args = ['--include=cairo-1.0']
+  else
+    regress_scanner_cairo_args = ['-D_GI_DISABLE_CAIRO',]
+  endif
+
+  regress_gir = custom_target('gir-regress',
     input: ['regress.c', 'regress.h', 'annotation.c', 'annotation.h',
             'foo.c', 'foo.h', 'drawable.c', 'drawable.h'],
     output: 'Regress-1.0.gir',
@@ -268,10 +280,16 @@ if glib_dep.type_name() == 'pkgconfig'
       '-L', meson.current_build_dir(),
       '-I', meson.current_source_dir(),
       '-I', join_paths(meson.current_source_dir(), '..'),
-      '-D_GI_DISABLE_CAIRO',
+      ] + regress_scanner_cairo_args + [
       '@INPUT@',
     ]
   )
+
+  # The reference gir is generated with cairo support, so we can only compare
+  # things if we build with cairo as well
+  if with_cairo
+    test_girs += regress_gir
+  endif
 endif
 
 foreach gir : test_girs


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