gst-plugins-rs/ci/generate-static-test.py
Jordan Petridis 12c058bc49 meson: Fix build of static plugins
While we were correctly skipping the plugins that couldn't be
built statically, we were still adding their names to the list
and the .pc list causing them to still get built.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/994>
2022-11-29 20:03:29 +02:00

72 lines
1.4 KiB
Python
Executable file

#!/usr/bin/env python3
# Generate a meson project statically linking on all plugins
import sys
import os
from utils import iterate_plugins
# the csound version used on ci does not ship a .pc file
IGNORE = ['csound', 'threadshare']
outdir = sys.argv[1]
plugins = list(filter(lambda p: p not in IGNORE, iterate_plugins()))
deps = list(
map(lambda p: " dependency('gst{}', static: true)".format(p), plugins))
deps = ',\n'.join(deps)
meson = """
project('test-gst-plugins-rs-static', 'c')
gst_deps = [
dependency('gstreamer-1.0'),
%s
]
executable('test-gst-static', ['main.c'],
dependencies: gst_deps,
)
""" % (deps)
declare = list(
map(lambda p: "GST_PLUGIN_STATIC_DECLARE({});".format(p), plugins))
declare = '\n'.join(declare)
register = list(
map(lambda p: "\tGST_PLUGIN_STATIC_REGISTER({});".format(p), plugins))
register = '\n'.join(register)
check = list(
map(lambda p: "\tg_assert (gst_registry_find_plugin(registry, \"{}\"));".format(p), plugins))
check = '\n'.join(check)
main = """
#include <gst/gst.h>
%s
int main(int argc, char **argv)
{
g_autoptr(GstRegistry) registry = NULL;
gst_init(&argc, &argv);
%s
registry = gst_registry_get();
%s
return 0;
}
""" % (declare, register, check)
os.makedirs(outdir)
meson_file = open(os.path.join(outdir, 'meson.build'), 'w')
meson_file.write(meson)
main_file = open(os.path.join(outdir, 'main.c'), 'w')
main_file.write(main)