[vte/wip/systemd: 6/6] systemd: Add option to disable systemd support



commit cc557aa310bab2c81b65fae22d2da4c46510d2e9
Author: Christian Persch <chpe src gnome org>
Date:   Tue Feb 4 18:13:47 2020 +0100

    systemd: Add option to disable systemd support

 meson.build       |  5 ++++-
 meson_options.txt |  7 +++++++
 src/meson.build   |  4 ++--
 src/pty.cc        | 11 +++++++----
 src/vtegtk.cc     |  8 ++++++++
 5 files changed, 28 insertions(+), 7 deletions(-)
---
diff --git a/meson.build b/meson.build
index 6963a19c..0643a636 100644
--- a/meson.build
+++ b/meson.build
@@ -440,12 +440,14 @@ else
   icu_dep = dependency('', required: false)
 endif
 
-if host_machine.system() == 'linux'
+if host_machine.system() == 'linux' and get_option('systemd')
   systemd_dep = dependency('libsystemd', version: '>=' + systemd_req_version)
 else
   systemd_dep = dependency('', required: false)
 endif
 
+config_h.set('WITH_SYSTEMD', systemd_dep.found())
+
 # Write config.h
 
 configure_file(
@@ -506,6 +508,7 @@ output += '  GTK+ 3.0:     ' + get_option('gtk3').to_string() + '\n'
 output += '  GTK+ 4.0:     ' + get_option('gtk4').to_string() + '\n'
 output += '  ICU:          ' + get_option('icu').to_string() + '\n'
 output += '  GIR:          ' + get_option('gir').to_string() + '\n'
+output += '  systemd:      ' + systemd_dep.found().to_string() + '\n'
 output += '  Vala:         ' + get_option('vapi').to_string() + '\n'
 output += '\n'
 output += '  Prefix:       ' + get_option('prefix') + '\n'
diff --git a/meson_options.txt b/meson_options.txt
index 47d54b78..c9aa50c8 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -85,6 +85,13 @@ option(
   description: 'Enable legacy charset support using ICU',
 )
 
+option(
+  'systemd',
+  type: 'boolean',
+  value: true,
+  description: 'Enable systemd support',
+)
+
 option(
   'vapi', # would use 'vala' but that name is reserved
   type: 'boolean',
diff --git a/src/meson.build b/src/meson.build
index 352b5af9..79d4a702 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -147,7 +147,7 @@ if get_option('icu')
   libvte_common_sources += icu_sources
 endif
 
-if host_machine.system() == 'linux'
+if systemd_dep.found()
   libvte_common_sources += systemd_sources
 endif
 
@@ -565,7 +565,7 @@ vte_sh = configure_file(
 
 # Systemd integration
 
-if host_machine.system() == 'linux'
+if systemd_dep.found()
   install_data(
     sources: 'vte-spawn-.scope.conf',
     install_dir: vte_systemduserunitdir / 'vte-spawn-.scope.d',
diff --git a/src/pty.cc b/src/pty.cc
index 1333c5d2..b0f56af8 100644
--- a/src/pty.cc
+++ b/src/pty.cc
@@ -74,7 +74,7 @@
 
 #include "glib-glue.hh"
 
-#ifdef __linux__
+#ifdef WITH_SYSTEMD
 #include "systemd.hh"
 #endif
 
@@ -396,7 +396,7 @@ Pty::spawn(char const* directory,
         int i;
         GPollFD pollfd;
 
-#ifndef __linux__
+#ifndef WITH_SYSTEMD
         if (spawn_flags & VTE_SPAWN_REQUIRE_SYSTEMD_SCOPE) {
                 g_set_error(error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
                             "systemd not available");
@@ -480,7 +480,7 @@ Pty::spawn(char const* directory,
         if (cancellable)
                 g_cancellable_release_fd(cancellable);
 
-#ifdef __linux__
+#ifdef WITH_SYSTEMD
         if (ret &&
             !(spawn_flags & VTE_SPAWN_NO_SYSTEMD_SCOPE) &&
             !vte::systemd::create_scope_for_pid_sync(pid,
@@ -497,10 +497,13 @@ Pty::spawn(char const* directory,
 
                         ret = false;
                 } else {
+                        _vte_debug_print(VTE_DEBUG_PTY,
+                                         "Failed to create systemd scope: %s",
+                                         err.message());
                         err.reset();
                 }
         }
-#endif // __linux__
+#endif // WITH_SYSTEMD
 
         if (!ret)
                 return err.propagate(error);
diff --git a/src/vtegtk.cc b/src/vtegtk.cc
index 33534b4c..8edb9d9b 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -1859,6 +1859,14 @@ vte_get_features (void)
 #else
                 "-ICU"
 #endif
+#ifdef __linux__
+                " "
+#ifdef WITH_SYSTEMD
+                "+SYSTEMD"
+#else
+                "-SYSTEMD"
+#endif
+#endif // __linux__
                 ;
 }
 


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