[gitg/wip/valadoc: 7/12] meson: Fix dependencies



commit 8b09eb18921fbf481d3e2173cdaeb05d565c04d4
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Fri Oct 5 07:32:30 2018 +0200

    meson: Fix dependencies
    
    Libraries build by gitg expose a number of includes in their public
    headers belonging to different libraries. Therefore, these libraries
    are indirect dependencies of the library to be built.
    
    With this in mind, these indirect dependencies are also included
    when a direct dependency is included, so there is no need to include
    them again.
    
    Dependency hierarchy has been fixed and duplicated dependencies
    removed.
    
    Created `pkg-config` files requirements have also been fixed.

 contrib/ide/meson.build   | 13 ++++++++++---
 contrib/xml/meson.build   |  8 ++++----
 gitg/meson.build          | 11 ++---------
 libgitg-ext/meson.build   | 32 ++++++++++++--------------------
 libgitg/meson.build       | 43 +++++++++++++++++++------------------------
 meson.build               |  5 +++++
 tests/gitg/meson.build    |  4 ----
 tests/libgitg/meson.build |  3 ---
 tests/meson.build         |  9 +--------
 9 files changed, 53 insertions(+), 75 deletions(-)
---
diff --git a/contrib/ide/meson.build b/contrib/ide/meson.build
index b728c493..27f03749 100644
--- a/contrib/ide/meson.build
+++ b/contrib/ide/meson.build
@@ -1,17 +1,24 @@
+common_deps = [
+  gio_dep,
+  glib_dep,
+]
+
 sources = files(
   'ide-doap.c',
   'ide-doap-person.c',
 )
 
+deps = common_deps + [libxml_reader_dep]
+
 libide = static_library(
   'ide',
   sources: sources,
   include_directories: top_inc,
-  dependencies: libxml_dep,
+  dependencies: deps,
 )
 
 libide_dep = declare_dependency(
-  link_with: libide,
   include_directories: include_directories('.'),
-  dependencies: valac.find_library('ide', dirs: meson.current_source_dir()),
+  dependencies: common_deps + [valac.find_library('ide', dirs: meson.current_source_dir())],
+  link_with: libide,
 )
diff --git a/contrib/xml/meson.build b/contrib/xml/meson.build
index b0f3c589..31d4b00a 100644
--- a/contrib/xml/meson.build
+++ b/contrib/xml/meson.build
@@ -2,18 +2,18 @@ sources = files('xml-reader.c')
 
 deps = [
   gio_dep,
-  dependency('libxml-2.0', version: '>= 2.9.0'),
+  libxml_dep,
 ]
 
-libxml = static_library(
+libxml_reader = static_library(
   'xml',
   sources: sources,
   include_directories: top_inc,
   dependencies: deps,
 )
 
-libxml_dep = declare_dependency(
-  link_with: libxml,
+libxml_reader_dep = declare_dependency(
   include_directories: include_directories('.'),
   dependencies: deps,
+  link_with: libxml_reader,
 )
diff --git a/gitg/meson.build b/gitg/meson.build
index e5c7e9d5..3f149996 100644
--- a/gitg/meson.build
+++ b/gitg/meson.build
@@ -54,19 +54,12 @@ sources = gitg_sources + files(
 
 deps = [
   config_dep,
-  gee_dep,
-  gio_dep,
   gitg_platform_support_dep,
-  glib_dep,
-  gtk_dep,
+  gobject_introspection_dep,
   gtksourceview_dep,
-  libgit2_glib_dep,
-  libgitg_dep,
+  gtkspell_dep,
   libgitg_ext_dep,
   libpeas_dep,
-  m_dep,
-  dependency('gobject-introspection-1.0', version: '>= 0.10.1'),
-  dependency('gtkspell3-3.0'),
 ]
 
 cflags = warn_flags + [
diff --git a/libgitg-ext/meson.build b/libgitg-ext/meson.build
index 4e2cdd2d..4963e534 100644
--- a/libgitg-ext/meson.build
+++ b/libgitg-ext/meson.build
@@ -35,13 +35,6 @@ sources = files(
   'gitg-ext-user-query.vala',
 )
 
-deps = [
-  gee_dep,
-  gtk_dep,
-  libgit2_glib_dep,
-  libgitg_dep,
-]
-
 cflags = warn_flags + [
   '-DDATADIR="@0@"'.format(gitg_datadir),
   '-DLIBDIR="@0@"'.format(gitg_libdir),
@@ -53,7 +46,7 @@ libgitg_ext = shared_library(
   version: libversion,
   soversion: soversion,
   include_directories: top_inc,
-  dependencies: deps,
+  dependencies: libgitg_dep,
   c_args: cflags,
   vala_header: lib_name + '.h',
   vala_vapi: lib_api_name + '.vapi',
@@ -69,9 +62,18 @@ libgitg_ext = shared_library(
   ],
 )
 
+deps = [
+  gee_dep,
+  gio_dep,
+  glib_dep,
+  gtk_dep,
+  libgit2_glib_dep,
+]
+
 libgitg_ext_dep = declare_dependency(
-  link_with: libgitg_ext,
   include_directories: include_directories('.'),
+  dependencies: deps + [libgitg_dep],
+  link_with: libgitg_ext,
 )
 
 pkg.generate(
@@ -81,17 +83,7 @@ pkg.generate(
   description: gitg_name + ' extensions library',
   filebase: lib_api_name,
   subdirs: lib_api_name,
-  requires: [
-    'gio-2.0',
-    'glib-2.0',
-    'gmodule-2.0',
-    'gobject-2.0',
-    'gtk+-3.0',
-    'gthread-2.0',
-    'libgit2-glib-1.0',
-    'libgitg-1.0',
-    gio_system_pkg,
-  ],
+  requires: deps +  ['libgitg-1.0'],
   variables: 'exec_prefix=' + gitg_prefix,
 )
 
diff --git a/libgitg/meson.build b/libgitg/meson.build
index 53b3da1d..473ff03d 100644
--- a/libgitg/meson.build
+++ b/libgitg/meson.build
@@ -9,6 +9,14 @@ gir_api_name = '@0@-@1@'.format(gir_ns, gitg_gir_version)
 gir_name = gir_api_name + '.gir'
 gir_typelib = gir_api_name + '.typelib'
 
+common_deps = [
+  gee_dep,
+  gio_dep,
+  glib_dep,
+  gtk_dep,
+  libgit2_glib_dep,
+]
+
 sources = files(
   'gitg-assembly-info.vala',
   'gitg-async.vala',
@@ -84,18 +92,14 @@ sources += gnome.compile_resources(
   dependencies: resource_data,
 )
 
-deps = [
-  gee_dep,
+deps = common_deps + [
   gitg_platform_support_dep,
-  glib_dep,
-  gtk_dep,
+  gsettings_desktop_schemas_dep,
   gtksourceview_dep,
-  libgit2_glib_dep,
   libide_dep,
+  libsecret_dep,
   libsoup_dep,
   m_dep,
-  dependency('gsettings-desktop-schemas'),
-  dependency('libsecret-1'),
 ]
 
 cflags = warn_flags + [
@@ -108,9 +112,8 @@ ldflags = common_ldflags
 
 if gdk_targets.contains('quartz')
   sources += files('gitg-platform-support-osx.c')
-  gio_system_pkg = 'gio-unix-2.0'
   deps += [
-    dependency(gio_system_pkg),
+    dependency('gio-unix-2.0'),
     find_library('objc'),
   ]
   cflags += '-xobjective-c'
@@ -121,12 +124,10 @@ if gdk_targets.contains('quartz')
   ])
 elif gdk_targets.contains('win32')
   sources += files('gitg-platform-support-win32.c')
-  gio_system_pkg = 'gio-windows-2.0'
-  deps += dependency(gio_system_pkg)
+  deps += dependency('gio-windows-2.0')
 else
   sources += files('gitg-platform-support.c')
-  gio_system_pkg = 'gio-unix-2.0'
-  deps += dependency(gio_system_pkg)
+  deps += dependency('gio-unix-2.0')
 endif
 
 libgitg = shared_library(
@@ -152,10 +153,13 @@ libgitg = shared_library(
 )
 
 libgitg_dep = declare_dependency(
-  link_with: libgitg,
   include_directories: include_directories('.'),
+  dependencies: common_deps + [m_dep],
+  link_with: libgitg,
 )
 
+# FIXME: libgitg_dep requires m_dep because math.h and float.h includes are exposed
+#        However, meson is not able to append it
 pkg.generate(
   libraries: libgitg,
   version: gitg_version,
@@ -163,16 +167,7 @@ pkg.generate(
   description: gitg_name + ' library',
   filebase: lib_api_name,
   subdirs: lib_api_name,
-  requires: [
-    'gio-2.0',
-    'glib-2.0',
-    'gmodule-2.0',
-    'gobject-2.0',
-    'gthread-2.0',
-    'gtk+-3.0',
-    'libgit2-glib-1.0',
-    gio_system_pkg,
-  ],
+  requires: common_deps,
   variables: 'exec_prefix=' + gitg_prefix,
 )
 
diff --git a/meson.build b/meson.build
index 1240cf38..fc0d0ad0 100644
--- a/meson.build
+++ b/meson.build
@@ -122,11 +122,16 @@ glib_req_version = '>= 2.38'
 gee_dep = dependency('gee-0.8')
 gio_dep = dependency('gio-2.0', version: glib_req_version)
 glib_dep = dependency('glib-2.0', version: glib_req_version)
+gobject_introspection_dep = dependency('gobject-introspection-1.0', version: '>= 0.10.1')
+gsettings_desktop_schemas_dep = dependency('gsettings-desktop-schemas')
 gtk_dep = dependency('gtk+-3.0', version: '>= 3.20.0')
+gtkspell_dep = dependency('gtkspell3-3.0')
 gtksourceview_dep = dependency('gtksourceview-3.0', version: '>= 3.10')
 libgit2_glib_dep = dependency('libgit2-glib-1.0', version: ['>= 0.25.0', '< 0.27.0'])
 libpeas_dep = dependency('libpeas-1.0')
+libsecret_dep = dependency('libsecret-1')
 libsoup_dep = dependency('libsoup-2.4')
+libxml_dep = dependency('libxml-2.0', version: '>= 2.9.0')
 
 config_dep = valac.find_library('config', dirs: vapi_dir)
 gitg_platform_support_dep = valac.find_library('gitg-platform-support', dirs: vapi_dir)
diff --git a/tests/gitg/meson.build b/tests/gitg/meson.build
index e3afd709..87803dd6 100644
--- a/tests/gitg/meson.build
+++ b/tests/gitg/meson.build
@@ -11,11 +11,7 @@ sources = gitg_sources + support_sources + files(
 
 deps = [
   config_dep,
-  gee_dep,
   gitg_assert_dep,
-  gtk_dep,
-  libgit2_glib_dep,
-  libgitg_dep,
   libgitg_ext_dep,
 ]
 
diff --git a/tests/libgitg/meson.build b/tests/libgitg/meson.build
index 427c1042..2c2c77cc 100644
--- a/tests/libgitg/meson.build
+++ b/tests/libgitg/meson.build
@@ -7,10 +7,7 @@ sources = support_sources + files(
 )
 
 deps = [
-  gee_dep,
   gitg_assert_dep,
-  gtk_dep,
-  libgit2_glib_dep,
   libgitg_dep,
 ]
 
diff --git a/tests/meson.build b/tests/meson.build
index 44da4ca1..6e4bdf41 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -2,13 +2,6 @@ subdir('support')
 subdir('libgitg')
 subdir('gitg')
 
-deps = [
-  gee_dep,
-  gtk_dep,
-  libgit2_glib_dep,
-  libgitg_dep,
-]
-
 test_names = [
   'diff-view',
   'repository-list-box',
@@ -20,7 +13,7 @@ foreach test_name: test_names
     'tests-' + test_name,
     sources: test_name + '.vala',
     include_directories: top_inc,
-    dependencies: deps,
+    dependencies: libgitg_dep,
     c_args: warn_flags,
   )
 endforeach


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