[mutter/bilelmoussaoui/build-without-gnome-desktop] meson: Allow to build without gnome-desktop




commit 450570f7693d01c189c57be4c60c3aeec443a778
Author: Bilal Elmoussaoui <belmouss redhat com>
Date:   Thu Mar 3 11:51:00 2022 +0100

    meson: Allow to build without gnome-desktop
    
    gnome-desktop is used to retrieve the monitor vendor name which in some use cases is not needed as it 
brings a bunch of gnome-desktop unwanted dependencies. The change makes mutter fallback to an "Undefined" 
vendor name if it is built without gnome-desktop

 config.h.meson                              |  3 +++
 meson.build                                 |  8 +++++++-
 meson_options.txt                           |  6 ++++++
 src/backends/meta-monitor-manager-private.h |  9 +++++++--
 src/backends/meta-monitor-manager.c         | 10 +++++++---
 src/meson.build                             |  7 ++++++-
 6 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/config.h.meson b/config.h.meson
index 027ebc5b2e..9119ad864e 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -46,6 +46,9 @@
 /* Defined if screen cast and remote desktop support is enabled */
 #mesondefine HAVE_REMOTE_DESKTOP
 
+/* Defined if gnome-desktop is enabled */
+#mesondefine HAVE_GNOME_DESKTOP
+
 /* Building with SM support */
 #mesondefine HAVE_SM
 
diff --git a/meson.build b/meson.build
index b6522f93d3..ec71c23f1a 100644
--- a/meson.build
+++ b/meson.build
@@ -106,7 +106,6 @@ gthread_dep = dependency('gobject-2.0', version: glib_req)
 gmodule_no_export_dep = dependency('gmodule-no-export-2.0', version: glib_req)
 gnome_settings_daemon_dep = dependency('gnome-settings-daemon')
 json_glib_dep = dependency('json-glib-1.0', version: json_glib_req)
-gnome_desktop_dep = dependency('gnome-desktop-3.0')
 xcomposite_dep = dependency('xcomposite', version: xcomposite_req)
 xcursor_dep = dependency('xcursor')
 xdamage_dep = dependency('xdamage')
@@ -133,6 +132,12 @@ dbus_dep = dependency('dbus-1')
 # For now always require X11 support
 have_x11 = true
 
+
+have_gnome_desktop = get_option('gnome-desktop')
+if have_gnome_desktop
+  gnome_desktop_dep = dependency('gnome-desktop-3.0')
+endif
+
 have_gl = get_option('opengl')
 if have_gl
   gl_dep = dependency('gl')
@@ -586,6 +591,7 @@ summary('Wayland EGLStream', have_wayland_eglstream, section: 'Options')
 summary('Native Backend', have_native_backend, section: 'Options')
 summary('EGL Device', have_egl_device, section: 'Options')
 summary('Remote desktop', have_remote_desktop, section: 'Options')
+summary('GNOME desktop', have_gnome_desktop, section: 'Options')
 summary('gudev', have_libgudev, section: 'Options')
 summary('Wacom', have_libwacom, section: 'Options')
 summary('SM', have_sm, section: 'Options')
diff --git a/meson_options.txt b/meson_options.txt
index 986199ce6f..a447804a85 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -57,6 +57,12 @@ option('remote_desktop',
   description: 'Enable remote desktop and screen cast support'
 )
 
+option('gnome_desktop',
+  type: 'boolean',
+  value: true,
+  description: 'Build with or without gnome-desktop'
+)
+
 option('egl_device',
   type: 'boolean',
   value: false,
diff --git a/src/backends/meta-monitor-manager-private.h b/src/backends/meta-monitor-manager-private.h
index 443ad14cd3..18ce2c4f23 100644
--- a/src/backends/meta-monitor-manager-private.h
+++ b/src/backends/meta-monitor-manager-private.h
@@ -26,7 +26,10 @@
 
 #include <cogl/cogl.h>
 #include <graphene.h>
-#include <libgnome-desktop/gnome-pnp-ids.h>
+
+#ifdef HAVE_GNOME_DESKTOP
+  #include <libgnome-desktop/gnome-pnp-ids.h>
+#endif
 
 #include "backends/meta-backend-private.h"
 #include "backends/meta-cursor.h"
@@ -155,7 +158,9 @@ struct _MetaMonitorManager
 
   MetaMonitorConfigManager *config_manager;
 
-  GnomePnpIds *pnp_ids;
+  #ifdef HAVE_GNOME_DESKTOP
+    GnomePnpIds *pnp_ids;
+  #endif
 
   MetaMonitorSwitchConfigType current_switch_config;
 
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index 2f7cfe2373..268861b663 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -3816,10 +3816,14 @@ char *
 meta_monitor_manager_get_vendor_name (MetaMonitorManager *manager,
                                       const char         *vendor)
 {
-  if (!manager->pnp_ids)
-    manager->pnp_ids = gnome_pnp_ids_new ();
+  #ifdef HAVE_GNOME_DESKTOP
+    if (!manager->pnp_ids)
+      manager->pnp_ids = gnome_pnp_ids_new ();
 
-  return gnome_pnp_ids_get_pnp_id (manager->pnp_ids, vendor);
+    return gnome_pnp_ids_get_pnp_id (manager->pnp_ids, vendor);
+  #endif
+
+  return g_strdup("Undefined");
 }
 
 gboolean
diff --git a/src/meson.build b/src/meson.build
index 43b28dc094..7b456f524f 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -23,13 +23,18 @@ mutter_pkg_deps = [
 
 mutter_pkg_private_deps = [
   gmodule_no_export_dep,
-  gnome_desktop_dep,
   gnome_settings_daemon_dep,
   json_glib_dep,
   libcanberra_dep,
   xkbcommon_dep,
 ]
 
+if have_gnome_desktop
+  mutter_pkg_private_deps += [
+    gnome_desktop_dep,
+  ]
+endif
+
 if have_gl
   mutter_pkg_deps += [
     gl_dep,


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