Simplify generate_plugins_path.py script
authorXavier Claessens <xavier.claessens@collabora.com>
Tue, 17 Sep 2019 19:53:40 +0000 (15:53 -0400)
committerXavier Claessens <xavier.claessens@collabora.com>
Wed, 4 Mar 2020 13:18:09 +0000 (08:18 -0500)
This also fix an empty plugin name being prepended to the list.

meson.build
scripts/generate_plugins_path.py

index 4b16d23..382eb42 100644 (file)
@@ -86,13 +86,11 @@ if build_system == 'windows'
   subproject('win-nasm')
 endif
 
-pathsep = host_machine.system() == 'windows' ? ';' : ':'
-
 subproject('orc', required: get_option('orc'))
 
 subprojects_names = []
 plugins_doc_caches = []
-all_plugins = ''
+all_plugins = []
 foreach sp : subprojects
   project_name = sp[0]
   build_infos = sp[1]
@@ -114,10 +112,7 @@ foreach sp : subprojects
     else
       plugins = []
     endif
-
-    foreach plugin: plugins
-      all_plugins += pathsep + plugin.full_path()
-    endforeach
+    all_plugins += plugins
 
     subprojects_names += [project_name]
     cmdres = run_command(python3, '-c', symlink.format(project_name, meson.current_source_dir()))
@@ -170,9 +165,18 @@ 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()))
+all_plugins_paths = []
+foreach plugin: all_plugins
+  all_plugins_paths += plugin.full_path()
+endforeach
+
+generate_plugins_paths = find_program('scripts/generate_plugins_path.py')
+configure_file(
+  output : 'GstPluginsPath.json',
+  command : [generate_plugins_paths,
+             '@OUTPUT@',
+             all_plugins_paths]
+)
 
 message('Building subprojects: ' + ', '.join(subprojects_names))
 setenv = find_program('gst-env.py')
index d57c60c..17a38f1 100644 (file)
@@ -6,14 +6,14 @@ 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")
+    parser.add_argument(dest="output", help="Output file")
+    parser.add_argument(dest="plugins", nargs=argparse.REMAINDER, help="The list of plugins")
 
     options = parser.parse_args()
 
     all_paths = set()
-    for plugin in options.plugins.split(os.pathsep):
+    for plugin in options.plugins:
         all_paths.add(os.path.dirname(plugin))
 
-    with open(os.path.join(options.builddir, 'GstPluginsPath.json'), "w") as f:
+    with open(options.output, "w") as f:
         json.dump(list(all_paths), f, indent=4, sort_keys=True)