[gvfs] build: Make monitors build commands common



commit c25bc351bb2605e57bc9a6d9250c9d4748c3d9e0
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Mon Dec 17 15:34:58 2018 +0100

    build: Make monitors build commands common
    
    All the available monitors install a set of files: volume monitor
    files, DBus service files, etc...
    
    These build commands are mostly common and only file names change,
    which are built using a given pattern. These build commands have
    been replaced by only one set of build commands that adapt to
    monitors needs by changing their name and simplifies the entire
    process.
    
    These changes also help installing `GOA` and `MTP` necessary test
    files.

 monitor/afc/meson.build     | 38 ------------------------
 monitor/goa/meson.build     | 36 -----------------------
 monitor/gphoto2/meson.build | 39 -------------------------
 monitor/meson.build         | 70 +++++++++++++++++++++++++++++++++++++++------
 monitor/mtp/meson.build     | 36 -----------------------
 monitor/udisks2/meson.build | 38 ------------------------
 test/meson.build            | 14 +--------
 7 files changed, 62 insertions(+), 209 deletions(-)
---
diff --git a/monitor/afc/meson.build b/monitor/afc/meson.build
index 0af5a8d3..741f64e5 100644
--- a/monitor/afc/meson.build
+++ b/monitor/afc/meson.build
@@ -1,41 +1,3 @@
-afc_monitor = files('afc.monitor')
-
-install_data(
-  afc_monitor,
-  install_dir: gvfs_remote_volume_monitors_dir
-)
-
-dbus_service = gvfs_namespace + '.AfcVolumeMonitor'
-dbus_exec = 'gvfs-afc-volume-monitor'
-dbus_systemd_service = ''
-
-if install_systemd_user_unit_dir
-  service = dbus_exec + '.service'
-
-  configure_file(
-    input: service + '.in',
-    output: service,
-    install: true,
-    install_dir: systemd_user_unit_dir,
-    configuration: service_conf
-  )
-
-  dbus_systemd_service = 'SystemdService=' + service
-endif
-
-dbus_service_conf = configuration_data()
-dbus_service_conf.set('service', dbus_service)
-dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
-dbus_service_conf.set('systemd_service', dbus_systemd_service)
-
-afc_service = configure_file(
-  input: dbus_service_in,
-  output: dbus_service + '.service',
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: dbus_service_conf
-)
-
 sources = files(
   'afcvolumemonitordaemon.c',
   'afcvolume.c',
diff --git a/monitor/goa/meson.build b/monitor/goa/meson.build
index 7be878ad..563d380c 100644
--- a/monitor/goa/meson.build
+++ b/monitor/goa/meson.build
@@ -1,39 +1,3 @@
-install_data(
-  'goa.monitor',
-  install_dir: gvfs_remote_volume_monitors_dir
-)
-
-dbus_service = gvfs_namespace + '.GoaVolumeMonitor'
-dbus_exec = 'gvfs-goa-volume-monitor'
-dbus_systemd_service = ''
-
-if install_systemd_user_unit_dir
-  service = dbus_exec + '.service'
-
-  configure_file(
-    input: service + '.in',
-    output: service,
-    install: true,
-    install_dir: systemd_user_unit_dir,
-    configuration: service_conf
-  )
-
-  dbus_systemd_service = 'SystemdService=' + service
-endif
-
-dbus_service_conf = configuration_data()
-dbus_service_conf.set('service', dbus_service)
-dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
-dbus_service_conf.set('systemd_service', dbus_systemd_service)
-
-configure_file(
-  input: dbus_service_in,
-  output: dbus_service + '.service',
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: dbus_service_conf
-)
-
 sources = files(
   'goavolumemonitordaemon.c',
   'goavolume.c',
diff --git a/monitor/gphoto2/meson.build b/monitor/gphoto2/meson.build
index c3f4c78a..63b4e8c7 100644
--- a/monitor/gphoto2/meson.build
+++ b/monitor/gphoto2/meson.build
@@ -1,42 +1,3 @@
-gphoto2_monitor = files('gphoto2.monitor')
-
-install_data(
-  gphoto2_monitor,
-  install_dir: gvfs_remote_volume_monitors_dir
-)
-
-
-dbus_service = gvfs_namespace + '.GPhoto2VolumeMonitor'
-dbus_exec = 'gvfs-gphoto2-volume-monitor'
-dbus_systemd_service = ''
-
-if install_systemd_user_unit_dir
-  service = dbus_exec + '.service'
-
-  configure_file(
-    input: service + '.in',
-    output: service,
-    install: true,
-    install_dir: systemd_user_unit_dir,
-    configuration: service_conf
-  )
-
-  dbus_systemd_service = 'SystemdService=' + service
-endif
-
-dbus_service_conf = configuration_data()
-dbus_service_conf.set('service', dbus_service)
-dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
-dbus_service_conf.set('systemd_service', dbus_systemd_service)
-
-gphoto2_service = configure_file(
-  input: dbus_service_in,
-  output: dbus_service + '.service',
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: dbus_service_conf
-)
-
 sources = files(
   'gphoto2-volume-monitor-daemon.c',
   'ggphoto2volume.c',
diff --git a/monitor/meson.build b/monitor/meson.build
index f841bdce..53e18806 100644
--- a/monitor/meson.build
+++ b/monitor/meson.build
@@ -1,21 +1,73 @@
 subdir('proxy')
 
-if enable_udisks2
-  subdir('udisks2')
+# [[service name suffix, install monitor test data]]
+monitors = []
+
+if enable_afc
+  monitors += [['Afc', true]]
 endif
 
-if enable_gphoto2
-  subdir('gphoto2')
+if enable_goa
+  monitors += [['Goa', false]]
 endif
 
-if enable_afc
-  subdir('afc')
+if enable_gphoto2
+  monitors += [['GPhoto2', true]]
 endif
 
 if enable_mtp
-  subdir('mtp')
+  monitors += [['MTP', false]]
 endif
 
-if enable_goa
-  subdir('goa')
+if enable_udisks2
+  monitors += [['UDisks2', true]]
 endif
+
+monitors_test_data = []
+foreach monitor: monitors
+  monitor_name = monitor[0].to_lower()
+
+  dbus_service = '@0@.@1@VolumeMonitor'.format(gvfs_namespace, monitor[0])
+  dbus_exec = 'gvfs-@0@-volume-monitor'.format(monitor_name)
+  dbus_systemd_service = ''
+
+  if install_systemd_user_unit_dir
+    service = dbus_exec + '.service'
+
+    configure_file(
+      input: join_paths(monitor_name, service + '.in'),
+      output: service,
+      install: true,
+      install_dir: systemd_user_unit_dir,
+      configuration: service_conf
+    )
+
+    dbus_systemd_service = 'SystemdService=' + service
+  endif
+
+  monitor_data = files(join_paths(monitor_name, monitor_name + '.monitor'))
+
+  install_data(
+    monitor_data,
+    install_dir: gvfs_remote_volume_monitors_dir
+  )
+
+  dbus_service_conf = configuration_data()
+  dbus_service_conf.set('service', dbus_service)
+  dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
+  dbus_service_conf.set('systemd_service', dbus_systemd_service)
+
+  monitor_service = configure_file(
+    input: dbus_service_in,
+    output: dbus_service + '.service',
+    install: true,
+    install_dir: dbus_service_dir,
+    configuration: dbus_service_conf
+  )
+
+  if monitor[1]
+    monitors_test_data += [monitor_data, monitor_service]
+  endif
+
+  subdir(monitor_name)
+endforeach
diff --git a/monitor/mtp/meson.build b/monitor/mtp/meson.build
index 77f47a16..ec94c688 100644
--- a/monitor/mtp/meson.build
+++ b/monitor/mtp/meson.build
@@ -1,39 +1,3 @@
-install_data(
-  'mtp.monitor',
-  install_dir: gvfs_remote_volume_monitors_dir
-)
-
-dbus_service = gvfs_namespace + '.MTPVolumeMonitor'
-dbus_exec = 'gvfs-mtp-volume-monitor'
-dbus_systemd_service = ''
-
-if install_systemd_user_unit_dir
-  service = dbus_exec + '.service'
-
-  configure_file(
-    input: service + '.in',
-    output: service,
-    install: true,
-    install_dir: systemd_user_unit_dir,
-    configuration: service_conf
-  )
-
-  dbus_systemd_service = 'SystemdService=' + service
-endif
-
-dbus_service_conf = configuration_data()
-dbus_service_conf.set('service', dbus_service)
-dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
-dbus_service_conf.set('systemd_service', dbus_systemd_service)
-
-configure_file(
-  input: dbus_service_in,
-  output: dbus_service + '.service',
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: dbus_service_conf
-)
-
 sources = files(
   'mtp-volume-monitor-daemon.c',
   'gmtpvolume.c',
diff --git a/monitor/udisks2/meson.build b/monitor/udisks2/meson.build
index d16339b2..26ccc142 100644
--- a/monitor/udisks2/meson.build
+++ b/monitor/udisks2/meson.build
@@ -1,41 +1,3 @@
-udisks2_monitor = files('udisks2.monitor')
-
-install_data(
-  udisks2_monitor,
-  install_dir: gvfs_remote_volume_monitors_dir
-)
-
-dbus_service = gvfs_namespace + '.UDisks2VolumeMonitor'
-dbus_exec = 'gvfs-udisks2-volume-monitor'
-dbus_systemd_service = ''
-
-if install_systemd_user_unit_dir
-  service = dbus_exec + '.service'
-
-  configure_file(
-    input: service + '.in',
-    output: service,
-    install: true,
-    install_dir: systemd_user_unit_dir,
-    configuration: service_conf
-  )
-
-  dbus_systemd_service = 'SystemdService=' + service
-endif
-
-dbus_service_conf = configuration_data()
-dbus_service_conf.set('service', dbus_service)
-dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
-dbus_service_conf.set('systemd_service', dbus_systemd_service)
-
-udisks2_service = configure_file(
-  input: dbus_service_in,
-  output: dbus_service + '.service',
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: dbus_service_conf
-)
-
 sources = files(
   'udisks2volumemonitordaemon.c',
   'gvfsudisks2drive.c',
diff --git a/test/meson.build b/test/meson.build
index 53c3c979..77d2044c 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -37,20 +37,8 @@ if enable_installed_tests
     metadata_service
   ]
 
-  if enable_afc
-    test_data += [afc_monitor, afc_service]
-  endif
-
-  if enable_gphoto2
-    test_data += [gphoto2_monitor, gphoto2_service]
-  endif
-
-  if enable_udisks2
-    test_data += [udisks2_monitor, udisks2_service]
-  endif
-
   install_data(
-    test_data,
+    test_data + monitors_test_data,
     install_dir: installed_tests_execdir
   )
 endif


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