Draft: Support prebuilt binaries
This is a work in progress patch to allow the use of prebuilt binaries. It uses the changes on system-deps#116
to automatically download and add to the pkg-config
path a binary archive with gstreamer, plugins and other required libraries. The goal is to allow users to compile gstreamer-rs
based projects without having to install the system libraries. The system-deps
merge request description has an in-depth explanation on how this works.
[package.metadata.system-deps.gstreamer_1_0]
name = "gstreamer"
url = "http://url/to/binaries.tar.gz"
checksum = "abcd1234"
provides = ["glib_2_0", "gobject_2_0", "gio_2_0", "gst*"]
In addition to the functionality of system-deps
, it leverages the same metadata parsing system to allow the users to specify gstreamer plugins in the manifest files. The same rules for inheritance and overriding apply as with the metadata in system-deps
.
# Project that uses gstreamer
[package.metadata.gstreamer-plugins]
include = ["a", "b", "c"]
While this works as a proof of concept, there are still some issues to sort out. The most pressing one is allowing to create a gstreamer_APP.so
shared library that bundles gstreamer and the selected plugins (plus gst_init_static_plugins
) inside, which the application will then be able to link against, very similar to gstreamer_full
. This is important for licensing and improved building times. We are still looking into how to do this, since Rust has some troubles to export external symbols in dylib
crates, so we may resort to using the C compiler directly in the build script. Another problem is that using too many plugins can cause a TOO_MANY_ARGUMENTS
error since the linking line is not deduplicated. This is planned in system-deps
, but it is not finished yet.
I'm adding this as a draft to keep track of the progress, get feedback and have some testing instructions to follow, but this is by no means stable or ready yet, and it will end up changing quite a bit. Any suggestions or comments are really appreciated c:
Testing
Build a binary archive for gstreamer
. While it may work with the uninstalled
folder of a regular build, we tested this using cerbero and manylinux for better compatibility. This should output a gstreamer-1.0-*.tar.xz
file.
# Clone cerbero
git clone https://gitlab.freedesktop.org/gstreamer/cerbero.git
# Enter a container using distrobox, toolbox, podman, distrobox, ...
distrobox create --image quay.io/pypa/manylinux_2_34_x86_64 --name cerbero
distrobox enter cerbero
# Setup the python version and requirements
export PATH=/opt/python/cp311-cp311/bin:$PATH
python3 -m pip install distro
# Bootstrap cerbero and build gstreamer
python3 cerbero-uninstalled bootstrap
python3 cerbero-uninstalled package -tn gstreamer-1.0
# Exit the container
In gstreamer/sys/Cargo.toml
, update the url
and checksum
values to point to the previously built archive.
[package.metadata.system-deps.gstreamer_1_0]
url = "file:///path/to/gstreamer-1.0-*.tar.xz" # This can also point to a folder where the archive was extracted
checksum = "abce..." # Get it with `sha256sum file.tar.xz`, not necessary for folders
To select which plugins to use, either add them to the include
list or use the environment variable GST_PLUGINS=name1,name2
. Then, you can enable the "binary" feature and build the project as usual.
cargo build --features "binary"
It is also possible to test projects using this library. For example, this patch for Servo is working without gstreamer
installed locally (though it is using my local binary file, you will need to patch that as before).