Generate the GST_PLUGIN_PATH using the `plugins` variable in subprojects
authorThibault Saunier <tsaunier@igalia.com>
Sun, 11 Nov 2018 23:06:04 +0000 (20:06 -0300)
committerThibault Saunier <tsaunier@igalia.com>
Mon, 13 May 2019 15:42:15 +0000 (11:42 -0400)
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
meson.build
scripts/generate_plugins_path.py [new file with mode: 0644]

index 11fa5dd..bb9143d 100755 (executable)
@@ -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)
 
index 5d8070a..c007e42 100644 (file)
@@ -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 (file)
index 0000000..8928824
--- /dev/null
@@ -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)