gst-env: Fix the gst plugin file path regex for Linux platforms
authorPhilippe Normand <philn@igalia.com>
Sat, 2 Nov 2019 15:27:16 +0000 (16:27 +0100)
committerPhilippe Normand <philn@igalia.com>
Wed, 6 Nov 2019 08:33:46 +0000 (09:33 +0100)
On Linux, the library file is stored in the platform triplet directory under the
lib directory (hence for example
lib/x86_64-linux-gnu/gstreamer-1.0/libgstfoo.so) so the regex needs to take this
into account.

With this change the LD_LIBRARY_PATH on Linux now contains only the directories
with gst libs, ignoring the plugins, as initially intended in
c6613d8da2191aaf2bd7d1ddd4130a289b02e1ba.

Fixes #56

gst-env.py

index c5e2fc8..d368a21 100755 (executable)
@@ -30,8 +30,11 @@ if not os.path.exists(DEFAULT_BUILDDIR):
 
 TYPELIB_REG = re.compile(r'.*\.typelib$')
 SHAREDLIB_REG = re.compile(r'\.so|\.dylib|\.dll')
-GSTPLUGIN_FILEPATH_REG = re.compile(r'.*/lib[^/]*/gstreamer-1.0/[^/]+$')
 
+# libdir is expanded from option of the same name listed in the `meson
+# introspect --buildoptions` output.
+GSTPLUGIN_FILEPATH_REG_TEMPLATE = r'.*/{libdir}/gstreamer-1.0/[^/]+$'
+GSTPLUGIN_FILEPATH_REG = None
 
 def listify(o):
     if isinstance(o, str):
@@ -84,6 +87,10 @@ def is_library_target_and_not_plugin(target, filename):
         # None of the installed files in the target correspond to the built
         # filename, so skip
         return False
+
+    global GSTPLUGIN_FILEPATH_REG
+    if GSTPLUGIN_FILEPATH_REG is None:
+        GSTPLUGIN_FILEPATH_REG = re.compile(GSTPLUGIN_FILEPATH_REG_TEMPLATE)
     if GSTPLUGIN_FILEPATH_REG.search(install_filename.replace('\\', '/')):
         return False
     return True
@@ -194,6 +201,15 @@ def get_subprocess_env(options, gst_version):
     paths = set()
     mono_paths = set()
     srcdir_path = pathlib.Path(options.srcdir)
+
+    build_options_s = subprocess.check_output(meson + ['introspect', options.builddir, '--buildoptions'])
+    build_options = json.loads(build_options_s.decode())
+    libdir, = [o['value'] for o in build_options if o['name'] == 'libdir']
+    libdir = libdir.replace('\\', '/')
+
+    global GSTPLUGIN_FILEPATH_REG_TEMPLATE
+    GSTPLUGIN_FILEPATH_REG_TEMPLATE = GSTPLUGIN_FILEPATH_REG_TEMPLATE.format(libdir=libdir)
+
     for target in targets:
         filenames = listify(target['filename'])
         for filename in filenames: