[gvfs] build: Apply a workaround for D-Bus code generation



commit 06c28a632d738b0141b619ea1c500d2563a20298
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Fri Mar 23 21:20:23 2018 +0100

    build: Apply a workaround for D-Bus code generation
    
    meson uses `gdbus-codegen` for D-Bus code generation. However, both
    files are generated implicitly, so meson is not able to know how
    many files are generated, so it does generate only one opaque
    target that represents the two files.
    
    A new script has been created only to call `gdbus-codegen` and
    simulate the generation of the source code and header as different
    targets.
    
    Please see:
      https://bugzilla.gnome.org/show_bug.cgi?id=791015
      https://github.com/mesonbuild/meson/pull/2930
    
    https://bugzilla.gnome.org/show_bug.cgi?id=794365

 codegen.py           |   28 ++++++++++++++++++++++++++++
 common/meson.build   |   18 ++++++++++++------
 meson.build          |    6 ++++++
 metadata/meson.build |   19 ++++++++++++-------
 4 files changed, 58 insertions(+), 13 deletions(-)
---
diff --git a/codegen.py b/codegen.py
new file mode 100755
index 0000000..9bc379c
--- /dev/null
+++ b/codegen.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+'''
+FIXME
+
+This script is used only to call gdbus-codegen and simulate the
+generation of the source code and header as different targets.
+
+Both are generated implicitly, so meson is not able to know how
+many files are generated, so it does generate only one opaque
+target that represents the two files.
+
+Please see:
+   https://bugzilla.gnome.org/show_bug.cgi?id=791015
+   https://github.com/mesonbuild/meson/pull/2930
+'''
+
+import subprocess
+import sys
+
+subprocess.call([
+  'gdbus-codegen',
+  '--interface-prefix=' + sys.argv[1],
+  '--generate-c-code=' + sys.argv[2],
+  '--c-namespace=' + sys.argv[3],
+  '--output-directory=' + sys.argv[4],
+  sys.argv[5]
+])
diff --git a/common/meson.build b/common/meson.build
index 226d98b..e269cb7 100644
--- a/common/meson.build
+++ b/common/meson.build
@@ -14,18 +14,23 @@ sources = files(
   'gvfsutils.c'
 )
 
-sources += gnome.gdbus_codegen(
-  'gvfsdbus',
-  gvfs_namespace + '.xml',
-  interface_prefix: gvfs_namespace + '.',
-  namespace: 'GVfsDBus'
+# FIXME: Ugly workaround that simulates the generation of
+#        two different targets.
+namespace = 'GVfsDBus'
+name = namespace.to_lower()
+
+dbus_sources = custom_target(
+  name,
+  input: gvfs_namespace + '.xml',
+  output: [name + '.c', name + '.h'],
+  command: [codegen, gvfs_namespace + '.', name, namespace, meson.current_build_dir(), '@INPUT@', '@OUTPUT@']
 )
 
 cflags = common_cflags + ['-DREMOTE_VOLUME_MONITORS_DIR="@0@"'.format(gvfs_remote_volume_monitors_dir)]
 
 libgvfscommon = shared_library(
   'gvfscommon',
-  sources: sources,
+  sources: sources + [dbus_sources],
   include_directories: top_inc,
   dependencies: glib_deps,
   c_args: cflags,
@@ -34,6 +39,7 @@ libgvfscommon = shared_library(
 )
 
 libgvfscommon_dep = declare_dependency(
+  sources: dbus_sources[1],
   link_with: libgvfscommon,
   include_directories: common_inc
 )
diff --git a/meson.build b/meson.build
index 70d35ba..52184db 100644
--- a/meson.build
+++ b/meson.build
@@ -462,6 +462,12 @@ endif
 enable_devel_utils = get_option('devel_utils')
 enable_installed_tests = get_option('installed_tests')
 
+# FIXME: Opaque target return from gdbus_codegen
+# Please see:
+#   https://bugzilla.gnome.org/show_bug.cgi?id=791015
+#   https://github.com/mesonbuild/meson/pull/2930
+codegen = join_paths(meson.source_root(), 'codegen.py')
+
 gnome = import('gnome')
 i18n = import('i18n')
 pkg = import('pkgconfig')
diff --git a/metadata/meson.build b/metadata/meson.build
index 4d47850..9eac076 100644
--- a/metadata/meson.build
+++ b/metadata/meson.build
@@ -29,11 +29,16 @@ metadata_service = configure_file(
   configuration: dbus_service_conf
 )
 
-metadata_dbus = gnome.gdbus_codegen(
-  'metadata-dbus',
-  'dbus-interface.xml',
-  interface_prefix: gvfs_namespace + '.',
-  namespace: 'GVfs'
+# FIXME: Ugly workaround that simulates the generation of
+#        two different targets.
+namespace = 'GVfs'
+name = 'metadata-dbus'
+
+dbus_sources = custom_target(
+  name,
+  input: 'dbus-interface.xml',
+  output: [name + '.c', name + '.h'],
+  command: [codegen, gvfs_namespace + '.', name, namespace, meson.current_build_dir(), '@INPUT@', '@OUTPUT@']
 )
 
 sources = files(
@@ -50,7 +55,7 @@ cflags = [
 
 libmetadata = static_library(
   'metadata',
-  sources: sources + [metadata_dbus],
+  sources: sources + [dbus_sources],
   include_directories: [top_inc, common_inc],
   dependencies: glib_deps,
   c_args: cflags,
@@ -58,7 +63,7 @@ libmetadata = static_library(
 )
 
 libmetadata_dep = declare_dependency(
-  sources: metadata_dbus,
+  sources: dbus_sources[1],
   link_with: libmetadata,
   include_directories: include_directories('.'),
   dependencies: glib_deps


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