WebKit Flatpak SDK and gst-build
This post is an annex of Phil’s Introducing the WebKit Flatpak SDK. Please make sure to read it, if you haven’t already.Recapitulating, nowadays WebKitGTK/WPE developers —and their CI infrastructure— are moving towards to Flatpak-based environment for their workflow. This Flatpak-based environment, or Flatpak SDK for short, can be visualized as a software sandboxed-container, which bundles all the dependencies required to compile, run and debug WebKitGTK/WPE.
In a day-by-day work, this approach removes the potential compilation of the world in order to obtain reproducible builds, improving the development and testing work flow.
But what if you are also involved in the development of one dependency?
This is the case of Igalia’s multimedia team where, besides developing the multimedia features for WebKitGTK and WPE, we also participate in the GStreamer development, the framework used for multimedia.
Because of this, in our workflow we usually need to build WebKit with a fix, hack or new feature in GStreamer. Is it possible to add in Flatpak our custom GStreamer build without messing its own GStreamer setup? Yes, it’s possible.
gst-build is a set of scripts in Python which clone GStreamer repositories, compile them and setup an uninstalled environment. This uninstalled environment allows a transient usage of the compiled framework from their build tree, avoiding installation and further mess up with our system.
The WebKit scripts that wraps Flatpak operations are also capable to handle the
scripts of gst-build
to build GStreamer inside the container, and, when
running WebKit’s artifacts, the scripts enable the mentioned uninstalled
environment, overloading Flatpak’s GStreamer.
How do we unveil all this magic?
First of all, setup a gst-build
installation as it is documented. In this
installation is were the GStreamer plumbing is done.
Later, gst-build
operations through WebKit compilation scripts are enabled
when the environment variable GST_BUILD_PATH
is exported. This variable should
point to the directory where the gst-build
tree is placed.
And that’s all!
But let’s put these words in actual commands. The following workflow assumes
that WebKit repository is cloned in ~/WebKit
and the gst-build
tree is in
~/gst-build
(please, excuse my bashisms).
Compiling WebKitGTK with symbols, using LLVM as toolchain (this command will also compile GStreamer):
cd ~/WebKit
CC=clang CXX=clang++ GST_BUILD_PATH=/home/vjaquez/gst-build Tools/Scripts/build-webkit --gtk --debug
Running the generated minibrowser (remind GST_BUILD_PATH
is required again for
a correct linking):
GST_BUILD_PATH=/home/vjaquez/gst-build Tools/Scripts/run-minibrowser --gtk --debug
Running media layout tests:
GST_BUILD_PATH=/home/vjaquez/gst-build ./Tools/Scripts/run-webkit-tests --gtk --debug media
But wait! There’s more….
What if you I want to parameterize the GStreamer compilation. To say, I would like to enable a GStreamer module or disable the built of a specific element.
gst-build
, as the rest of GStreamer modules, uses
meson build system, so it’s possible to pass
arguments to meson through the environment variable GST_BUILD_ARGS
.
For example, I would like to enable gstreamer-vaapi 😇
cd ~/WebKit
CC=clang CXX=clang++ GST_BUILD_PATH=/home/vjaquez/gst-build GST_BUILD_ARGS="-Dvaapi=enabled" Tools/Scripts/build-webkit --gtk --debug