Commit 3b1a8402 authored by Christian Hergert's avatar Christian Hergert
Browse files

doc: add a bit of info on Runtimes

parent f1c82a3e
###################################
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment