[dconf: 8/21] build: Fix internal dependencies



commit c50f3758d3e5da4f8b244227b211c3c3f454275c
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Tue Apr 10 22:50:31 2018 +0200

    build: Fix internal dependencies
    
    meson is able to generate internal dependencies for handling built
    libraries. These internal dependencies depend on other dependencies
    as well, based on the includes exposed by their headers.
    
    This have been fixed by using proper internal dependencies for these
    libraries.

 bin/meson.build       |  1 +
 client/meson.build    | 30 ++++++++++++++----------------
 common/meson.build    | 10 ++++++++++
 engine/meson.build    | 12 +++++++++++-
 gdbus/meson.build     | 26 ++++++++++++++++++--------
 gsettings/meson.build | 16 ++++++----------
 gvdb/meson.build      | 12 +++++++++++-
 meson.build           |  7 ++++---
 service/meson.build   | 14 ++++++++------
 shm/meson.build       | 11 ++++++++---
 tests/meson.build     | 16 ++++++++--------
 11 files changed, 99 insertions(+), 56 deletions(-)
---
diff --git a/bin/meson.build b/bin/meson.build
index 5dc5035..d81cb29 100644
--- a/bin/meson.build
+++ b/bin/meson.build
@@ -6,6 +6,7 @@ sources = gvdb_builder + libdconf_vapi + files(
 )
 
 deps = [
+  libdconf_common_dep,
   libdconf_dep,
   valac.find_library('posix')
 ]
diff --git a/client/meson.build b/client/meson.build
index 7767ce6..579bce0 100644
--- a/client/meson.build
+++ b/client/meson.build
@@ -10,42 +10,40 @@ install_headers(
   subdir: join_paths(meson.project_name(), 'client')
 )
 
-sources = files('dconf-client.c')
+name = meson.project_name() + '-client'
 
 cflags = '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name())
 
 libdconf_client = static_library(
-  meson.project_name() + '-client',
-  sources: sources,
+  name,
+  sources: name + '.c',
   include_directories: top_inc,
-  dependencies: gio_unix_dep,
+  dependencies: libdconf_gdbus_thread_dep,
   c_args: cflags,
   pic: true
 )
 
+libdconf_client_dep = declare_dependency(
+  dependencies: gio_dep,
+  link_with: libdconf_client
+)
+
 libdconf = shared_library(
   meson.project_name(),
-  sources: sources,
+  sources: name + '.c',
   version: libversion,
   soversion: soversion,
   include_directories: top_inc,
-  dependencies: gio_unix_dep,
+  dependencies: deps,
   c_args: cflags,
-  link_with: [
-    libdconf_common,
-    libdconf_engine,
-    libdconf_gdbus_thread,
-    libdconf_shm,
-    libgvdb
-  ],
   install: true,
   install_dir: dconf_libdir
 )
 
 libdconf_dep = declare_dependency(
-  link_with: libdconf,
   include_directories: client_inc,
-  dependencies: gio_unix_dep
+  dependencies: gio_dep,
+  link_with: libdconf
 )
 
 pkg.generate(
@@ -55,7 +53,7 @@ pkg.generate(
   description: meson.project_name() + ' client library',
   filebase: meson.project_name(),
   subdirs: meson.project_name(),
-  requires: 'gio-unix-2.0 ' + gio_unix_req_version,
+  requires: 'gio-2.0 ' + gio_req_version,
   variables: 'exec_prefix=' + dconf_libexecdir,
   install_dir: join_paths(dconf_libdir, 'pkgconfig')
 )
diff --git a/common/meson.build b/common/meson.build
index 6aed690..51eb939 100644
--- a/common/meson.build
+++ b/common/meson.build
@@ -30,6 +30,11 @@ libdconf_common = static_library(
   pic: true
 )
 
+libdconf_common_dep = declare_dependency(
+  dependencies: glib_dep,
+  link_with: libdconf_common
+)
+
 cflags += cc.get_supported_arguments('-fvisibility=hidden')
 
 libdconf_common_hidden = static_library(
@@ -40,3 +45,8 @@ libdconf_common_hidden = static_library(
   c_args: cflags,
   pic: true
 )
+
+libdconf_common_hidden_dep = declare_dependency(
+  dependencies: glib_dep,
+  link_with: libdconf_common_hidden
+)
diff --git a/engine/meson.build b/engine/meson.build
index d68bd5e..c4ed442 100644
--- a/engine/meson.build
+++ b/engine/meson.build
@@ -8,13 +8,23 @@ sources = files(
   'dconf-engine-source-system.c'
 )
 
+deps = [
+  libdconf_common_dep,
+  libgvdb_dep
+]
+
 cflags = '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name())
 
 libdconf_engine = static_library(
   meson.project_name() + '-engine',
   sources: sources,
   include_directories: top_inc,
-  dependencies: glib_dep,
+  dependencies: deps + [libdconf_shm_dep],
   c_args: cflags,
   pic: true
 )
+
+libdconf_engine_dep = declare_dependency(
+  dependencies: deps,
+  link_with: libdconf_engine
+)
diff --git a/gdbus/meson.build b/gdbus/meson.build
index c22a81d..1aef9fb 100644
--- a/gdbus/meson.build
+++ b/gdbus/meson.build
@@ -1,23 +1,33 @@
-sources = files('dconf-gdbus-thread.c')
+name = meson.project_name() + '-gdbus-thread'
 
 cflags = '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name())
 
 libdconf_gdbus_thread = static_library(
-  meson.project_name() + '-gdbus-thread',
-  sources: sources,
+  name,
+  sources: name + '.c',
   include_directories: top_inc,
-  dependencies: gio_unix_dep,
+  dependencies: libdconf_engine_dep,
   c_args: cflags,
   pic: true
 )
 
-sources = files('dconf-gdbus-filter.c')
+libdconf_gdbus_thread_dep = declare_dependency(
+  dependencies: libdconf_engine_dep,
+  link_with: libdconf_gdbus_thread
+)
+
+name = meson.project_name() + '-gdbus-filter'
 
 libdconf_gdbus_filter = static_library(
-  meson.project_name() + '-gdbus-filter',
-  sources: sources,
+  name,
+  sources: name + '.c',
   include_directories: top_inc,
-  dependencies: gio_unix_dep,
+  dependencies: libdconf_engine_dep,
   c_args: cflags,
   pic: true
 )
+
+libdconf_gdbus_filter_dep = declare_dependency(
+  dependencies: libdconf_engine_dep,
+  link_with: libdconf_gdbus_filter
+)
diff --git a/gsettings/meson.build b/gsettings/meson.build
index 51bf5c0..c1e9104 100644
--- a/gsettings/meson.build
+++ b/gsettings/meson.build
@@ -1,20 +1,16 @@
-sources = files('dconfsettingsbackend.c')
+deps = [
+  libdconf_common_hidden_dep,
+  libdconf_gdbus_thread_dep
+]
 
 cflags = '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name())
 
 libdconf_settings = shared_library(
   meson.project_name() + 'settings',
-  sources: sources,
+  sources: 'dconfsettingsbackend.c',
   include_directories: top_inc,
-  dependencies: gio_unix_dep,
+  dependencies: deps,
   c_args: cflags,
-  link_with: [
-    libdconf_common_hidden,
-    libdconf_engine,
-    libdconf_gdbus_thread,
-    libdconf_shm,
-    libgvdb
-  ],
   install: true,
   install_dir: gio_module_dir
 )
diff --git a/gvdb/meson.build b/gvdb/meson.build
index 735d268..5010e27 100644
--- a/gvdb/meson.build
+++ b/gvdb/meson.build
@@ -2,13 +2,23 @@ gvdb_builder = files('gvdb-builder.c')
 
 sources = gvdb_builder + files('gvdb-reader.c')
 
+deps = [
+  gio_dep,
+  glib_dep
+]
+
 cflags = '-DG_LOG_DOMAIN="gvdb (via @0@)"'.format(meson.project_name())
 
 libgvdb = static_library(
   'gvdb',
   sources: sources,
   include_directories: top_inc,
-  dependencies: glib_dep,
+  dependencies: deps,
   c_args: cflags,
   pic: true
 )
+
+libgvdb_dep = declare_dependency(
+  dependencies: deps,
+  link_with: libgvdb
+)
diff --git a/meson.build b/meson.build
index 93c14dc..c2532ad 100644
--- a/meson.build
+++ b/meson.build
@@ -44,12 +44,13 @@ endif
 
 add_project_arguments(common_flags, language: 'c')
 
-gio_unix_req_version = '>= 2.25.7'
+gio_req_version = '>= 2.25.7'
 
+gio_dep = dependency('gio-2.0', version: gio_req_version)
+gio_unix_dep = dependency('gio-unix-2.0', version: gio_req_version)
 glib_dep = dependency('glib-2.0', version: '>= 2.44.0')
-gio_unix_dep = dependency('gio-unix-2.0', version: gio_unix_req_version)
 
-gio_module_dir = dependency('gio-2.0').get_pkgconfig_variable('giomoduledir', define_variable: ['libdir', 
dconf_libdir])
+gio_module_dir = gio_dep.get_pkgconfig_variable('giomoduledir', define_variable: ['libdir', dconf_libdir])
 dbus_session_service_dir = dependency('dbus-1').get_pkgconfig_variable('session_bus_services_dir', 
define_variable: ['datadir', dconf_datadir])
 
 configure_file(
diff --git a/service/meson.build b/service/meson.build
index 87184aa..9e79a87 100644
--- a/service/meson.build
+++ b/service/meson.build
@@ -28,16 +28,18 @@ sources += gnome.gdbus_codegen(
   namespace: 'DConfDBus'
 )
 
+deps = [
+  gio_unix_dep,
+  libdconf_common_dep,
+  libdconf_shm_dep,
+  libgvdb_dep,
+]
+
 executable(
   'dconf-service',
   sources,
   include_directories: top_inc,
-  dependencies: gio_unix_dep,
-  link_with: [
-    libdconf_common,
-    libdconf_shm,
-    libgvdb
-  ],
+  dependencies: deps,
   install: true,
   install_dir: dconf_libexecdir
 )
diff --git a/shm/meson.build b/shm/meson.build
index d904cd0..4f95b98 100644
--- a/shm/meson.build
+++ b/shm/meson.build
@@ -1,12 +1,17 @@
-sources = files('dconf-shm.c')
+name = meson.project_name() + '-shm'
 
 cflags = '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name())
 
 libdconf_shm = static_library(
-  meson.project_name() + '-shm',
-  sources: sources,
+  name,
+  sources: name + '.c',
   include_directories: top_inc,
   dependencies: glib_dep,
   c_args: cflags,
   pic: true
 )
+
+libdconf_shm_dep = declare_dependency(
+  dependencies: glib_dep,
+  link_with: libdconf_shm
+)
diff --git a/tests/meson.build b/tests/meson.build
index 0ec6cbe..83bb446 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -22,14 +22,14 @@ m_dep = cc.find_library('m')
 
 unit_tests = [
   # [name, sources, c_args, dependencies, link_with]
-  ['paths', 'paths.c', [], glib_dep, libdconf_common],
-  ['changeset', 'changeset.c', [], glib_dep, libdconf_common],
-  ['shm', ['shm.c', 'tmpdir.c'], [], [glib_dep, dl_dep], libdconf_shm],
-  ['gvdb', 'gvdb.c', '-DSRCDIR="@0@"'.format(test_dir), glib_dep, libgvdb],
-  ['gdbus-thread', 'dbus.c', '-DDBUS_BACKEND="/gdbus/thread"', gio_unix_dep, libdconf_gdbus_thread],
-  ['gdbus-filter', 'dbus.c', '-DDBUS_BACKEND="/gdbus/filter"', gio_unix_dep, libdconf_gdbus_filter],
-  ['engine', 'engine.c', '-DSRCDIR="@0@"'.format(test_dir), [glib_dep, dl_dep, m_dep], [libdconf_engine, 
libdconf_common, libdconf_mock]],
-  ['client', 'client.c', '-DSRCDIR="@0@"'.format(test_dir), gio_unix_dep, [libdconf_client, libdconf_engine, 
libdconf_common, libdconf_mock]]
+  ['paths', 'paths.c', [], libdconf_common_dep, []],
+  ['changeset', 'changeset.c', [], libdconf_common_dep, []],
+  ['shm', ['shm.c', 'tmpdir.c'], [], [dl_dep, libdconf_common_dep, libdconf_shm_dep], []],
+  ['gvdb', 'gvdb.c', '-DSRCDIR="@0@"'.format(test_dir), libgvdb_dep, []],
+  ['gdbus-thread', 'dbus.c', '-DDBUS_BACKEND="/gdbus/thread"', libdconf_gdbus_thread_dep, []],
+  ['gdbus-filter', 'dbus.c', '-DDBUS_BACKEND="/gdbus/filter"', libdconf_gdbus_filter_dep, []],
+  ['engine', 'engine.c', '-DSRCDIR="@0@"'.format(test_dir), [dl_dep, libdconf_engine_dep, m_dep], 
libdconf_mock],
+  ['client', 'client.c', '-DSRCDIR="@0@"'.format(test_dir), [libdconf_client_dep, libdconf_engine_dep], 
libdconf_mock]
 ]
 
 foreach unit_test: unit_tests


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