[tracker-miners/sam/safe-auto-build-options: 2/3] build: Remove battery_detection=auto build time option




commit 0ed1d3d6fd97f196e8761f80e2fbf71e63640675
Author: Sam Thursfield <sam thursfield codethink co uk>
Date:   Tue Aug 30 18:47:00 2022 +0200

    build: Remove battery_detection=auto build time option
    
    Our preferred backend is upower, this is now the default. Systems where
    upower is not available (mostly BSD systems) must now opt into HAL
    explicitly.
    
    For rationale: https://blogs.gnome.org/mcatanzaro/2022/07/15/best-practices-for-build-options/

 meson.build       | 38 ++++++++++++--------------------------
 meson_options.txt |  2 +-
 2 files changed, 13 insertions(+), 27 deletions(-)
---
diff --git a/meson.build b/meson.build
index b0dde707a..f605c6bbf 100644
--- a/meson.build
+++ b/meson.build
@@ -79,7 +79,6 @@ libtiff = dependency('libtiff-4', required: get_option('tiff'))
 libxml2 = dependency('libxml-2.0', version: '>= 2.6', required: get_option('xml'))
 poppler = dependency('poppler-glib', version: '>= 0.16.0', required: get_option('pdf'))
 totem_plparser = dependency('totem-plparser', required: get_option('playlist'))
-upower = dependency('upower-glib', version: '>= 0.9.0', required: false)
 blkid = dependency('blkid', required: true)
 
 libgif = cc.find_library('gif', required: get_option('gif'))
@@ -141,35 +140,22 @@ add_project_arguments(debug_cflags, language: 'c')
 
 ##################################################################
 # Check for libtracker-common: battery/mains power detection
-#
-# By default, AUTO with this order of preference:
-#  1)  upower
-#  2)  hal
 ##################################################################
 
-have_hal = false
-battery_detection_library_name = ''
+battery_detection_help = 'You can use the "battery_detection" config option to select a different backend or 
set `-Dbattery_detection=none` to disable this feature.',
+battery_detection_library_name = get_option('battery_detection')
+if battery_detection_library_name == 'upower'
+  upower = dependency('upower-glib',
+    version: '>= 0.9.0',
+    not_found_message: battery_detection_help)
 
-if upower.found()
-  if get_option('battery_detection') == 'auto' or get_option('battery_detection') == 'upower'
-    battery_detection_library = upower
-    battery_detection_library_name = 'upower'
-  endif
-elif get_option('battery_detection') == 'upower'
-  error('upower explicitly requested, but upower library was not found')
-endif
+  battery_detection_library = upower
+elif battery_detection_library_name == 'hal'
+  hal = dependency('hal',
+    version: '>= 0.5',
+    not_found_message: battery_detection_help)
 
-if battery_detection_library_name == ''
-  hal = dependency('hal', version: '>= 0.5', required: false)
-
-  if hal.found()
-    battery_detection_library = hal
-    battery_detection_library_name = 'hal'
-  elif get_option('battery_detection') == 'hal'
-    error('HAL explicitly requested, but not found')
-  else
-    battery_detection_library_name = '(none)'
-  endif
+  battery_detection_library = hal
 endif
 
 ##########################################
diff --git a/meson_options.txt b/meson_options.txt
index 0173bba71..c59ee7ee9 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -74,7 +74,7 @@ option('xmp', type: 'feature', value: 'auto',
 option('xps', type: 'feature', value: 'auto',
        description: 'Support extracting metadata from XPS documents')
 
-option('battery_detection', type: 'combo', choices: ['auto', 'hal', 'upower', 'none'], value: 'auto',
+option('battery_detection', type: 'combo', choices: ['upower', 'hal', 'none'], value: 'upower',
        description: 'Enable upower or HAL for battery/mains power detection')
 option('charset_detection', type: 'combo', choices: ['auto', 'enca', 'icu', 'none'], value: 'auto',
        description: 'Enable enca or libicu for charset detection in MP3s')


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