From 954c27641d77339db7d90aa69099d6a89727e2ba Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Sat, 19 Nov 2016 18:01:44 -0300 Subject: [PATCH] Use mesonintrospect to set library path this way the uninstalled target can be used before the libraries are built https://bugzilla.gnome.org/show_bug.cgi?id=775281 --- common.py | 15 +++++++++++++++ gst-uninstalled.py | 40 ++++++++++++++++++++++------------------ setup | 12 ++---------- 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/common.py b/common.py index 40f420eb20..8c8b55dfb6 100644 --- a/common.py +++ b/common.py @@ -1,7 +1,12 @@ import argparse +import os import shutil import subprocess + +ROOTDIR = os.path.abspath(os.path.dirname(__file__)) + + class Colors: HEADER = '\033[95m' OKBLUE = '\033[94m' @@ -47,3 +52,13 @@ def accept_command(commands): return command return None + +def get_meson(): + meson = os.path.join(ROOTDIR, 'meson', 'meson.py') + if os.path.exists(meson): + mesonconf = os.path.join(ROOTDIR, 'meson', 'mesonconf.py') + mesonintrospect = os.path.join(ROOTDIR, 'meson', 'mesonintrospect.py') + return meson, mesonconf, mesonintrospect + + return accept_command(["meson.py", "meson"]), accept_command(["mesonconf.py", "mesonconf"]), \ + accept_command(["mesonintrospect.py", "mesonintrospect"]) diff --git a/gst-uninstalled.py b/gst-uninstalled.py index 14778f71ad..890ab512b8 100755 --- a/gst-uninstalled.py +++ b/gst-uninstalled.py @@ -1,13 +1,16 @@ #!/usr/bin/env python3 import argparse +import json import os +import platform import re import site import shutil import subprocess import tempfile +from common import get_meson SCRIPTDIR = os.path.abspath(os.path.dirname(__file__)) @@ -59,7 +62,7 @@ def get_subprocess_env(options): env["GST_REGISTRY"] = os.path.normpath(options.builddir + "/registry.dat") filename = "meson.build" - sharedlib_reg = re.compile(r'\.so$|\.dylib$|\.dll$') + sharedlib_reg = re.compile(r'\.so|\.dylib|\.dll') typelib_reg = re.compile(r'.*\.typelib$') if os.name is 'nt': @@ -69,23 +72,24 @@ def get_subprocess_env(options): else: lib_path_envvar = 'LD_LIBRARY_PATH' - for root, dirnames, filenames in os.walk(os.path.join(options.builddir, - 'subprojects')): - has_typelib = False - has_shared = False - for filename in filenames: - if typelib_reg.search(filename) and not has_typelib: - has_typelib = True - prepend_env_var(env, "GI_TYPELIB_PATH", - os.path.join(options.builddir, root)) - if has_shared: - break - elif sharedlib_reg.search(filename) and not has_shared: - has_shared = True - prepend_env_var(env, lib_path_envvar, - os.path.join(options.builddir, root)) - if has_typelib: - break + meson, mesonconf, mesonintrospect = get_meson() + targets_s = subprocess.check_output([mesonintrospect, options.builddir, '--targets']) + targets = json.loads(targets_s.decode()) + for target in targets: + filename = target['filename'] + root = os.path.dirname(filename) + if typelib_reg.search(filename): + prepend_env_var(env, "GI_TYPELIB_PATH", + os.path.join(options.builddir, root)) + elif sharedlib_reg.search(filename): + if target.get('type') != "shared library": + continue + + if "lib/gstreamer-1.0" in os.path.normpath(target.get('install_filename')): + continue + + prepend_env_var(env, lib_path_envvar, + os.path.join(options.builddir, root)) return env diff --git a/setup b/setup index 3f768578f7..489878e07a 100755 --- a/setup +++ b/setup @@ -8,6 +8,7 @@ import shutil import subprocess from common import git +from common import get_meson from common import Colors from common import accept_command @@ -17,22 +18,13 @@ PROJECTNAME = "GStreamer build" ROOTDIR = os.path.abspath(os.path.dirname(__file__)) -def get_meson(): - meson = os.path.join(ROOTDIR, 'meson', 'meson.py') - if os.path.exists(meson): - mesonconf = os.path.join(ROOTDIR, 'meson', 'mesonconf.py') - return meson, mesonconf - - return accept_command(["meson.py", "meson"]), accept_command(["mesonconf.py", "mesonconf"]) - - def get_configs(): return ['--werror'] def configure_meson(args, options): """Configures meson and generate the Makefile.""" - meson, mesonconf = get_meson() + meson, mesonconf, mesonintrospect = get_meson() if not meson: print("Install mesonbuild to build %s: http://mesonbuild.com/\n" "You can simply install it with:\n"