[gnome-usage] build: Add libhandy 0.82.0 dependency



commit 1361897a9144437152f1b32309c43c736a6f4a18
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Tue Sep 10 13:31:59 2019 +0200

    build: Add libhandy 0.82.0 dependency
    
    Also add it as a submodule so it can work on systems where libhandy
    isn't packaged, like the CI.

 .gitmodules          |  3 +++
 meson.build          | 42 +++++++++++++++++++++++++++++++++++++++++-
 src/meson.build      |  3 ++-
 subprojects/libhandy |  1 +
 4 files changed, 47 insertions(+), 2 deletions(-)
---
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..e0fed8a
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "subprojects/libhandy"]
+       path = subprojects/libhandy
+       url = https://gitlab.gnome.org/GNOME/libhandy.git
diff --git a/meson.build b/meson.build
index 48c6039..f28f229 100644
--- a/meson.build
+++ b/meson.build
@@ -2,7 +2,7 @@ project(
   'gnome-usage', ['vala', 'c'],
   version: '3.33.2',
   license: 'GPL3',
-  meson_version: '>= 0.37.0'
+  meson_version: '>= 0.38.0'
 )
 
 cc = meson.get_compiler('c')
@@ -15,14 +15,54 @@ gio_unix_dep = dependency('gio-unix-2.0')
 gtk_dep = dependency('gtk+-3.0', version : '>=3.20.10')
 libdazzle_dep = dependency('libdazzle-1.0', version : '>=3.30')
 libgtop_dep = dependency('libgtop-2.0', version : '>= 2.34.0')
+libhandy_dep = dependency('libhandy-1', version : '>= 0.82.0', required: false)
 tracker_dep = dependency('tracker-sparql-2.0')
 
+if not libhandy_dep.found()
+  libhandy_subproj = subproject(
+    'libhandy',
+    default_options: [
+      'examples=false',
+      'glade_catalog=disabled',
+      'tests=false',
+    ]
+  )
+
+  # When using libhandy as subproject, make sure we get the VAPI file
+  libhandy_dep = declare_dependency(
+    dependencies: [
+      libhandy_subproj.get_variable('libhandy_dep'),
+      libhandy_subproj.get_variable('libhandy_vapi'),
+    ]
+  )
+
+  libhandy_vapidir = join_paths(meson.build_root(), 'subprojects', 'libhandy', 'src')
+else
+  libhandy_vapidir = ''
+endif
+
 gnome = import('gnome')
 i18n = import('i18n')
 
+add_project_arguments (
+  '-DHANDY_USE_UNSTABLE_API',
+  language: 'c'
+)
+
+add_project_arguments (
+  # FIXME Drop once we depend on libhandy 1.0.
+  '--disable-since-check',
+  language: 'vala'
+)
+
 po_dir = join_paths(meson.source_root(), 'po')
 vapi_dir = join_paths (meson.source_root (), 'vapi')
 
+vapi_dirs = [ '--vapidir=@0@'.format(vapi_dir) ]
+if libhandy_vapidir != ''
+  vapi_dirs += '--vapidir=@0@'.format(libhandy_vapidir)
+endif
+
 if get_option('profile') == 'development'
   profile = 'Devel'
   name_suffix = ' (Development)'
diff --git a/src/meson.build b/src/meson.build
index aa1b736..b7f4c57 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -57,6 +57,7 @@ deps = [
   libgtop_dep,
   tracker_dep,
   libdazzle_dep,
+  libhandy_dep,
   cc.find_library('m'),
   valac.find_library('config', dirs: vapi_dir),
   valac.find_library('stopgap', dirs: vapi_dir),
@@ -77,6 +78,6 @@ executable(
   vala_sources + resources,
   dependencies: deps,
   c_args: c_args,
-  vala_args: '--vapidir=' + vapi_dir,
+  vala_args: vapi_dirs,
   install: true
 )
diff --git a/subprojects/libhandy b/subprojects/libhandy
new file mode 160000
index 0000000..cc83397
--- /dev/null
+++ b/subprojects/libhandy
@@ -0,0 +1 @@
+Subproject commit cc833973c6fc78a83ea9d06f62c9f9b8047fa914


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