From fbb81c6c78e098550687fd3758e9a6e515c5e00e Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sun, 11 Nov 2018 20:06:04 -0300 Subject: [PATCH] Generate the GST_PLUGIN_PATH using the `plugins` variable in subprojects To build the documentation, we are maintaining a 'standardise' `plugins` variable accross all modules to list all plugins and generate documentation for them. This is also used to get the right plugin path when inspecting plugins for the documentation. --- gst-uninstalled.py | 9 ++++----- meson.build | 20 ++++++++++---------- scripts/generate_plugins_path.py | 19 +++++++++++++++++++ 3 files changed, 33 insertions(+), 15 deletions(-) create mode 100644 scripts/generate_plugins_path.py diff --git a/gst-uninstalled.py b/gst-uninstalled.py index 11fa5dd0de..bb9143da3a 100755 --- a/gst-uninstalled.py +++ b/gst-uninstalled.py @@ -81,7 +81,6 @@ def get_subprocess_env(options, gst_version): sharedlib_reg = re.compile(r'\.so|\.dylib|\.dll') typelib_reg = re.compile(r'.*\.typelib$') - pluginpath_reg = re.compile(r'lib.*' + re.escape(os.path.normpath('/gstreamer-1.0/'))) if os.name is 'nt': lib_path_envvar = 'PATH' @@ -133,16 +132,16 @@ def get_subprocess_env(options, gst_version): elif sharedlib_reg.search(filename): if not target['type'].startswith('shared'): continue - if target['installed']: - if pluginpath_reg.search(os.path.normpath(stringify(target['install_filename']))): - prepend_env_var(env, "GST_PLUGIN_PATH", os.path.join(options.builddir, root)) - continue prepend_env_var(env, lib_path_envvar, os.path.join(options.builddir, root)) elif target['type'] == 'executable' and target['installed']: paths.add(os.path.join(options.builddir, root)) + with open(os.path.join(options.builddir, 'GstPluginsPath.json')) as f: + for plugin_path in json.load(f): + prepend_env_var(env, 'GST_PLUGIN_PATH', plugin_path) + for p in paths: prepend_env_var(env, 'PATH', p) diff --git a/meson.build b/meson.build index 5d8070a4a6..c007e42341 100644 --- a/meson.build +++ b/meson.build @@ -80,16 +80,12 @@ foreach sp : subprojects subproj = subproject(project_name, required: is_required) endif - if subproj.found() - if build_infos.has_key('build-hotdoc', default: false) - foreach plugin: subproj.get_variable('plugins') - all_plugins += plugin.full_path() - endforeach - if documented_projects != '' - documented_projects += ',' - endif - - documented_projects += project_name + if subproj.found() and build_infos.has_key('build-hotdoc', default: false) + foreach plugin: subproj.get_variable('plugins') + all_plugins += plugin.full_path() + endforeach + if documented_projects != '' + documented_projects += ',' endif documented_projects += project_name @@ -123,6 +119,10 @@ else endif endif +cmdres = run_command(python3, find_program('scripts/generate_plugins_path.py'), '--builddir', + meson.build_root(), all_plugins) +assert(cmdres.returncode() == 0, 'Could not create plugins path: @0@'.format(cmdres.stderr())) + message('Building subprojects: ' + ', '.join(subprojects_names)) setenv = find_program('gst-uninstalled.py') run_target('uninstalled', command : [setenv, '--builddir=@0@'.format(meson.build_root()), diff --git a/scripts/generate_plugins_path.py b/scripts/generate_plugins_path.py new file mode 100644 index 0000000000..89288244c3 --- /dev/null +++ b/scripts/generate_plugins_path.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3 + +import argparse +import os +import json + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument("--builddir", help="The meson build directory") + parser.add_argument(dest="plugins", help="The list of plugins", nargs="+") + + options = parser.parse_args() + + all_paths = set() + for plugin in options.plugins: + all_paths.add(os.path.dirname(plugin)) + + with open(os.path.join(options.builddir, 'GstPluginsPath.json'), "w") as f: + json.dump(list(all_paths), f, indent=4, sort_keys=True)