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




commit b63436837a9ed93a110bc8dc5fbf37170affba21
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 | 11 +++++++++--
 src/backends/meta-monitor-manager.c         | 10 ++++++----
 src/backends/meta-monitor.c                 |  8 ++++++--
 src/meson.build                             |  7 ++++++-
 7 files changed, 43 insertions(+), 10 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..ea4eb09e83 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;
 
@@ -424,8 +429,10 @@ void meta_monitor_manager_clear_crtc (MetaCrtc *crtc);
 
 gboolean meta_monitor_has_aspect_as_size (MetaMonitor *monitor);
 
+#ifdef HAVE_GNOME_DESKTOP
 char * meta_monitor_manager_get_vendor_name (MetaMonitorManager *manager,
                                              const char         *vendor);
+#endif
 
 static inline MetaOutputAssignment *
 meta_find_output_assignment (MetaOutputAssignment **outputs,
diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c
index 2f7cfe2373..8294dc955e 100644
--- a/src/backends/meta-monitor-manager.c
+++ b/src/backends/meta-monitor-manager.c
@@ -3812,15 +3812,17 @@ meta_monitor_manager_get_config_manager (MetaMonitorManager *manager)
  * Returns: (transfer full): A string containing the vendor name,
  *                           or NULL when not found.
  */
+#ifdef HAVE_GNOME_DESKTOP
 char *
 meta_monitor_manager_get_vendor_name (MetaMonitorManager *manager,
                                       const char         *vendor)
-{
-  if (!manager->pnp_ids)
-    manager->pnp_ids = gnome_pnp_ids_new ();
+{ 
+    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
 
 gboolean
 meta_monitor_manager_get_panel_orientation_managed (MetaMonitorManager *manager)
diff --git a/src/backends/meta-monitor.c b/src/backends/meta-monitor.c
index 46cb05a666..942bb0403b 100644
--- a/src/backends/meta-monitor.c
+++ b/src/backends/meta-monitor.c
@@ -263,8 +263,12 @@ meta_monitor_make_display_name (MetaMonitor        *monitor,
 
   if (g_strcmp0 (vendor, "unknown") != 0)
     {
-      vendor_name = meta_monitor_manager_get_vendor_name (monitor_manager,
-                                                          vendor);
+      #ifdef HAVE_GNOME_DESKTOP
+        vendor_name = meta_monitor_manager_get_vendor_name (monitor_manager,
+                                                            vendor);
+      #else
+        vendor_name = g_strdup("Undefined");
+      #endif
 
       if (!vendor_name)
         vendor_name = g_strdup (vendor);
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]