[gnome-builder] doc: add a bit of info on Runtimes
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] doc: add a bit of info on Runtimes
- Date: Tue, 14 Mar 2017 22:17:46 +0000 (UTC)
commit 3b1a84024a3c5ebead761386c33ae428662b4dbe
Author: Christian Hergert <chergert redhat com>
Date: Tue Mar 14 15:17:36 2017 -0700
doc: add a bit of info on Runtimes
doc/plugins/processes/runtimes.rst | 42 ++++++++++++++++++++++++++++++++++++
1 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/doc/plugins/processes/runtimes.rst b/doc/plugins/processes/runtimes.rst
index d138fa1..56a8eb5 100644
--- a/doc/plugins/processes/runtimes.rst
+++ b/doc/plugins/processes/runtimes.rst
@@ -1,3 +1,45 @@
###################################
Application Runtimes and Containers
###################################
+
+A core abstraction in the design of builder is ``Ide.Runtime``.
+This provides a way to setup and execute processes within a given environment.
+That environment could be your host operating system, a container, a build environment, or even a remote
system.
+
+For example, if we want to run the ``make`` command for your project and that project is targeting the GNOME
Sdk we need to first enter the SDK environment.
+The Flatpak_ plugin provides an ``Ide.Runtime`` implementation to do this so that before your subprocess is
lanched, the runtime is setup and initialized for execution with an alternate mount namespace, network
namespace, and more.
+
+How to get a runtime
+====================
+
+If you need to run a process within the build environment you will want to access the runtime for the
current build configuration.
+The current build configuration can be accessed from the ``Ide.ConfigurationManager`` object.
+
+.. code-block:: py
+
+ config_manager = context.get_configuration_manager()
+ config = config_manager.get_current()
+ runtime = config.get_runtime()
+
+.. note:: It is possible that the configured runtime does not yet exist, so remember to check for ``None``.
+
+
+Creating a Subprocess
+=====================
+
+To create a subprocess in the runtime, use the ``Ide.Subprocess.create_launcher()`` method and then spawn a
process using that launcher.
+
+.. code-block:: py
+
+ try:
+ launcher = runtime.create_launcher()
+ launcher.push_argv('which')
+ launcher.push_argv('make')
+ subprocess = launcher.spawn(None)
+ _, stdout, stderr = subprocess.communicate_utf8(None, None)
+ except Exception as ex:
+ print("Failed to create launcher: " + repr(ex))
+ return
+
+
+.. _Flatpak: https://flatpak.org
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]