diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0b6a516f..2d62833a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -166,8 +166,13 @@ meson shared: meson static: extends: .img-stable 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 + - ./build/test-gst-static rules: - if: '$UPDATE_IMG == null || $UPDATE_IMG == "stable"' diff --git a/ci/generate-static-test.py b/ci/generate-static-test.py new file mode 100755 index 00000000..b4c75d8e --- /dev/null +++ b/ci/generate-static-test.py @@ -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 + +%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)