[gnome-settings-daemon/benzea/systemd-3-36] meson: Move stub desktop file generation into plugins loop



commit 317f3d548a72a067344ed115e5aa824adfc7b373
Author: Benjamin Berg <bberg redhat com>
Date:   Thu Dec 12 01:09:30 2019 +0100

    meson: Move stub desktop file generation into plugins loop
    
    There is no need to have two places for desktop file generation for
    services that can be disabled. Instead, integrate the logic into the
    main plugin loop and simply use a different template file as the input.
    
    To implement this, create a list of disabled modules that can be tested
    to skip the generation of the systemd units and inclusion of the plugin
    directory.

 plugins/dummy/meson.build | 30 -----------------
 plugins/meson.build       | 84 +++++++++++++++++++++++++----------------------
 2 files changed, 44 insertions(+), 70 deletions(-)
---
diff --git a/plugins/meson.build b/plugins/meson.build
index e249d49b..0b3a10e9 100644
--- a/plugins/meson.build
+++ b/plugins/meson.build
@@ -1,8 +1,7 @@
-enabled_plugins = [
-  ['a11y-settings', 'A11ySettings', ''],
-  ['color', 'Color', ''],
+all_plugins = [
+  ['a11y-settings', 'A11ySettings'],
+  ['color', 'Color'],
   ['datetime', 'Datetime'],
-  ['dummy', ''],
   ['power', 'Power'],
   ['housekeeping', 'Housekeeping'],
   ['keyboard', 'Keyboard'],
@@ -10,27 +9,34 @@ enabled_plugins = [
   ['screensaver-proxy', 'ScreensaverProxy'],
   ['sharing', 'Sharing'],
   ['sound', 'Sound'],
-  ['xsettings', 'XSettings']
+  ['xsettings', 'XSettings'],
+  ['smartcard', 'Smartcard'],
+  ['wacom', 'Wacom'],
+  ['print-notifications', 'PrintNotifications'],
+  ['rfkill', 'Rfkill'],
+  ['wwan', 'Wwan'],
 ]
 
-if enable_smartcard
-  enabled_plugins += [['smartcard', 'Smartcard']]
+disabled_plugins = []
+
+if not enable_smartcard
+  disabled_plugins += ['smartcard']
 endif
 
-if enable_wacom
-  enabled_plugins += [['wacom', 'Wacom', 'wacom.target.wants/']]
+if not enable_wacom
+  disabled_plugins += ['wacom']
 endif
 
-if enable_cups
-  enabled_plugins += [['print-notifications', 'PrintNotifications']]
+if not enable_cups
+  disabled_plugins += ['cups']
 endif
 
-if enable_rfkill
-  enabled_plugins += [['rfkill', 'Rfkill']]
+if not enable_rfkill
+  disabled_plugins += ['rfkill']
 endif
 
-if enable_wwan
-  enabled_plugins += [['wwan', 'Wwan']]
+if not enable_wwan
+  disabled_plugins += ['wwan']
 endif
 
 plugin_install_wants = {
@@ -42,13 +48,12 @@ plugin_install_wants = {
 
 plugins_conf = configuration_data()
 plugins_conf.set('libexecdir', gsd_libexecdir)
-plugins_conf.set('systemd_hidden', enable_systemd ? 'true' : 'false')
 
 plugins_deps = [libgsd_dep]
 
 plugins_cflags = ['-DGNOME_SETTINGS_LOCALEDIR="@0@"'.format(gsd_localedir)]
 
-enabled_plugins_file = []
+all_plugins_file = []
 
 cflags = [
   '-DG_LOG_DOMAIN="common"'
@@ -56,33 +61,39 @@ cflags = [
 plugin_name = 'common'
 subdir('common')
 
-foreach plugin: enabled_plugins
+foreach plugin: all_plugins
   plugin_name = plugin[0]
+  plugin_name_case = plugin[1]
+  plugin_dbus_name='org.gnome.SettingsDaemon.@0@'.format(plugin_name_case)
+
   desktop = 'org.gnome.SettingsDaemon.@0@.desktop'.format(plugin[1])
 
-  if plugin[1] == '' # dummy
-    desktop_in_file = ''
+  if disabled_plugins.contains(plugin_name)
+    desktop_in_file = files(join_paths('dummy', 'org.gnome.SettingsDaemon.Dummy.desktop.in'))
   else
     desktop_in_file = files(join_paths(plugin_name, desktop + '.in'))
   endif
 
-  enabled_plugins_file += [[plugin_name, plugin[1], desktop_in_file]]
-endforeach
-
-foreach plugin: enabled_plugins_file
-  plugin_name = plugin[0]
-  plugin_name_case = plugin[1]
-  plugin_dbus_name='org.gnome.SettingsDaemon.@0@'.format(plugin_name_case)
-
   cflags = [
     '-DG_LOG_DOMAIN="@0@-plugin"'.format(plugin_name),
     '-DPLUGIN_NAME="@0@"'.format(plugin_name),
     '-DPLUGIN_DBUS_NAME="@0@"'.format(plugin_dbus_name),
   ] + plugins_cflags
 
-  if plugin_name != 'dummy'
-    desktop = 'org.gnome.SettingsDaemon.@0@.desktop'.format(plugin[1])
-    desktop_in_file = plugin[2]
+  desktop = 'org.gnome.SettingsDaemon.@0@.desktop'.format(plugin[1])
+  desktop_conf = configuration_data()
+  desktop_conf.set('libexecdir', gsd_libexecdir)
+  desktop_conf.set('systemd_hidden', enable_systemd ? 'true' : 'false')
+  desktop_conf.set('pluginname', plugin_name)
+  configure_file(
+    input: desktop_in_file,
+    output: desktop,
+    configuration: desktop_conf,
+    install: true,
+    install_dir: gsd_xdg_autostart
+  )
+
+  if not disabled_plugins.contains(plugin_name)
     user_target = 'gsd-@0@.target'.format(plugin_name)
     user_service = 'gsd-@0@.service'.format(plugin_name)
 
@@ -90,13 +101,6 @@ foreach plugin: enabled_plugins_file
     unit_conf.set('libexecdir', gsd_libexecdir)
     unit_conf.set('plugin_dbus_name', plugin_dbus_name)
 
-    configure_file(
-      input: desktop_in_file,
-      output: desktop,
-      configuration: plugins_conf,
-      install: true,
-      install_dir: gsd_xdg_autostart
-    )
     if enable_systemd
       configure_file(
         input: join_paths(plugin_name, user_service + '.in'),
@@ -119,7 +123,7 @@ foreach plugin: enabled_plugins_file
        endforeach
      endif
    endif
-  endif
 
-  subdir(plugin_name)
+    subdir(plugin_name)
+  endif
 endforeach


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