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



commit 028f221367af9b18b49396e54859bb0bb763720b
Author: Christian Persch <chpe src gnome org>
Date:   Sun Feb 2 23:11:16 2020 +0100

    build: Add option to disable systemd support

 meson.build       | 5 ++++-
 meson_options.txt | 7 +++++++
 src/meson.build   | 2 +-
 src/pty.cc        | 9 ++++++---
 src/vtegtk.cc     | 6 ++++++
 5 files changed, 24 insertions(+), 5 deletions(-)
---
diff --git a/meson.build b/meson.build
index 845acb01..427b3e1c 100644
--- a/meson.build
+++ b/meson.build
@@ -436,12 +436,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(
@@ -502,6 +504,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 4242dd61..a18f6294 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
 
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 080095ef..c6f649d0 100644
--- a/src/vtegtk.cc
+++ b/src/vtegtk.cc
@@ -1858,6 +1858,12 @@ vte_get_features (void)
                 "+ICU"
 #else
                 "-ICU"
+#endif
+                " "
+#ifdef WITH_SYSTEMD
+                "+SYSTEMD"
+#else
+                "-SYSTEMD"
 #endif
                 ;
 }


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