ci: test linking on all static plugins

Will ensure that our static libraries and pkg-config files are properly
generated.
This commit is contained in:
Guillaume Desmottes 2020-11-27 13:44:04 +01:00
parent 9167e5e561
commit fdc3ea68e8
2 changed files with 77 additions and 1 deletions

View file

@ -166,8 +166,13 @@ meson shared:
meson static: meson static:
extends: .img-stable extends: .img-stable
script: script:
- meson build --default-library=static - meson build --default-library=static --prefix=$(pwd)/install -Dsodium=built-in
- ninja -C build install
- ./ci/generate-static-test.py test-static-link-all
- cd test-static-link-all
- PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$(pwd)/../install/lib/x86_64-linux-gnu/pkgconfig meson build
- ninja -C build - ninja -C build
- ./build/test-gst-static
rules: rules:
- if: '$UPDATE_IMG == null || $UPDATE_IMG == "stable"' - if: '$UPDATE_IMG == null || $UPDATE_IMG == "stable"'

71
ci/generate-static-test.py Executable file
View file

@ -0,0 +1,71 @@
#!/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']
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)