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



commit 9f226558012b7b91e510f53e8741155cda956c73
Author: Christian Persch <chpe src gnome org>
Date:   Tue Feb 4 16:10:26 2020 +0100

    systemd: Add option to disable systemd support

 meson.build       | 5 ++++-
 meson_options.txt | 7 +++++++
 src/meson.build   | 4 ++--
 src/pty.cc        | 9 ++++++---
 src/vtegtk.cc     | 8 ++++++++
 5 files changed, 27 insertions(+), 6 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..0a10c610 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
 
@@ -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]