[tracker-miners/sam/meson-options-cleanup] Clean up Meson options



commit bd00a96cf565d209021a11e79e832a115185c50f
Author: Sam Thursfield <sam afuera me uk>
Date:   Tue Feb 25 14:47:23 2020 +0100

    Clean up Meson options
    
    Closes https://gitlab.gnome.org/GNOME/tracker-miners/issues/49

 meson.build                       | 42 +++++++++++++++++----------------------
 meson_options.txt                 | 10 ++++++----
 src/miners/fs/meson.build         |  2 +-
 src/miners/rss/meson.build        |  2 +-
 src/tracker-extract/meson.build   |  2 +-
 src/tracker-writeback/meson.build |  2 +-
 6 files changed, 28 insertions(+), 32 deletions(-)
---
diff --git a/meson.build b/meson.build
index 4958d506c..7c498b57c 100644
--- a/meson.build
+++ b/meson.build
@@ -33,12 +33,7 @@ if get_option('tracker_core') == 'system'
   tracker_uninstalled_testutils_dir = tracker_testutils.get_pkgconfig_variable('python_path')
   tracker_uninstalled_nepomuk_ontologies_dir = 
join_paths(tracker_sparql.get_pkgconfig_variable('ontologies_dir'), 'nepomuk')
 else
-  tracker_subproject = subproject('tracker',
-    default_options: [
-       'dbus_services=@0@'.format(get_option('dbus_services')),
-       'docs=@0@'.format(get_option('docs')),
-       'systemd_user_services=@0@'.format(get_option('systemd_user_services')),
-    ])
+  tracker_subproject = subproject('tracker')
 
   tracker_sparql = tracker_subproject.get_variable('tracker_sparql_dep')
 
@@ -281,35 +276,34 @@ endif
 # D-Bus service files
 ####################################################################
 
-if get_option('dbus_services') == ''
+dbus_services_dir = get_option('dbus_services_dir')
+if dbus_services_dir == ''
   dbus_services_dir = dbus.get_pkgconfig_variable('session_bus_services_dir',
                                                   define_variable: [ 'datadir', datadir ])
-else
-  dbus_services_dir = get_option('dbus_services')
 endif
 
 ####################################################################
 # systemd user services
 ####################################################################
 
-install_systemd_user_services = false
-if get_option('systemd_user_services') == 'yes' or get_option('systemd_user_services') == 'auto'
-  systemd = dependency('systemd', required: false)
-  if systemd.found()
-    install_systemd_user_services = true
-    systemd_user_services_dir = join_paths(libdir, 'systemd', 'user')
-  else
-    install_systemd_user_services = false
-    systemd_user_services_dir = '(not found)'
+if get_option('systemd_user_services')
+  systemd_user_services_dir = get_option('systemd_user_services_dir')
+
+  if systemd_user_services_dir == ''
+    systemd = dependency('systemd', required: false)
+    if systemd.found()
+      # FIXME: this would ideally use the systemduserunitdir pkgconfig variable, but
+      # it does not depend on variables we can override to install within prefix.
+      systemd_user_services_dir = join_paths(libdir, 'systemd', 'user')
+    else
+      error('systemd user services were enabled, but systemd was not found. ' +
+            'Please set the systemd_user_services_dir option if you want to ' +
+            'install them, or set systemd_user_services=false to disable.')
+    endif
   endif
-elif get_option('systemd_user_services') == 'no' or get_option('systemd_user_services') == ''
-  install_systemd_user_services = false
-  systemd_user_services_dir = '(disabled)'
-else
-  install_systemd_user_services = true
-  systemd_user_services_dir = get_option('systemd_user_services')
 endif
 
+
 conf = configuration_data()
 
 # Config that goes in config.h
diff --git a/meson_options.txt b/meson_options.txt
index 87ce733ad..46dbc7117 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -79,7 +79,9 @@ option('generic_media_extractor', type: 'combo', choices: ['auto', 'gstreamer',
 option('gstreamer_backend', type: 'combo', choices: ['discoverer', 'gupnp'], value: 'discoverer',
        description: 'When GStreamer is used, this enables one of the (discoverer, gupnp) GStreamer backends')
 
-option('dbus_services', type: 'string', value: '',
-       description: 'Directory to install D-Bus .service files (leave blank to use the value from 
dbus-1.pc)')
-option('systemd_user_services', type: 'string', value: 'yes',
-       description: 'Directory to install systemd user .service files (or "yes" for default directory, "no" 
to disable installation)')
+option('dbus_services_dir', type: 'string',
+       description: 'Directory to install D-Bus .service files (value from dbus-1.pc is used by default)')
+option('systemd_user_services', type: 'boolean', value: true,
+       description: 'Whether to install systemd user .service files')
+option('systemd_user_services_dir', type: 'string',
+       description: 'Directory to install systemd user .service files (value from systemd.pc is used by 
default)')
diff --git a/src/miners/fs/meson.build b/src/miners/fs/meson.build
index b58bfbd71..ba5f5af79 100644
--- a/src/miners/fs/meson.build
+++ b/src/miners/fs/meson.build
@@ -58,7 +58,7 @@ desktop_file = custom_target('tracker-miner-fs-desktop-file',
     install: true,
     install_dir: join_paths(get_option('sysconfdir'), 'xdg/autostart'))
 
-if install_systemd_user_services
+if get_option('systemd_user_services')
   configure_file(
       input: 'tracker-miner-fs.service.in',
       output: 'tracker-miner-fs.service',
diff --git a/src/miners/rss/meson.build b/src/miners/rss/meson.build
index 239394049..4f698f31d 100644
--- a/src/miners/rss/meson.build
+++ b/src/miners/rss/meson.build
@@ -35,7 +35,7 @@ desktop_file = custom_target('tracker-miner-rss-desktop-file',
     install: true,
     install_dir: join_paths(get_option('sysconfdir'), 'xdg/autostart'))
 
-if install_systemd_user_services
+if get_option('systemd_user_services')
   configure_file(
       input: 'tracker-miner-rss.service.in',
       output: 'tracker-miner-rss.service',
diff --git a/src/tracker-extract/meson.build b/src/tracker-extract/meson.build
index aa9abaf04..a730b3a8a 100644
--- a/src/tracker-extract/meson.build
+++ b/src/tracker-extract/meson.build
@@ -193,7 +193,7 @@ desktop_file = custom_target('tracker-extract-desktop-file',
   install: true,
   install_dir: join_paths(get_option('sysconfdir'), 'xdg/autostart'))
 
-if install_systemd_user_services
+if get_option('systemd_user_services')
   configure_file(
     input: 'tracker-extract.service.in',
     output: 'tracker-extract.service',
diff --git a/src/tracker-writeback/meson.build b/src/tracker-writeback/meson.build
index 168c71508..70bcf65cb 100644
--- a/src/tracker-writeback/meson.build
+++ b/src/tracker-writeback/meson.build
@@ -56,7 +56,7 @@ dbus_service_file = configure_file(
   install: true,
   install_dir: dbus_services_dir)
 
-if install_systemd_user_services
+if get_option('systemd_user_services')
   configure_file(
     input: 'tracker-writeback.service.in',
     output: 'tracker-writeback.service',


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