+def is_binary_target_and_in_path(target, filename, bindir):
+ if target['type'] != 'executable':
+ return False
+ # Check if this file installed by this target is installed to bindir
+ install_filename = get_target_install_filename(target, filename)
+ if not install_filename:
+ return False
+ fpath = PurePath(install_filename)
+ if fpath.parent != bindir:
+ return False
+ return True
+
+
+def get_wine_subprocess_env(options, env):
+ with open(os.path.join(options.builddir, 'meson-info', 'intro-buildoptions.json')) as f:
+ buildoptions = json.load(f)
+
+ prefix, = [o for o in buildoptions if o['name'] == 'prefix']
+ path = os.path.normpath(os.path.join(prefix['value'], 'bin'))
+ prepend_env_var(env, "PATH", path, options.sysroot)
+ wine_path = get_wine_shortpath(
+ options.wine.split(' '),
+ [path] + env.get('WINEPATH', '').split(';')
+ )
+ if options.winepath:
+ wine_path += ';' + options.winepath
+ env['WINEPATH'] = wine_path
+ env['WINEDEBUG'] = 'fixme-all'
+
+ return env
+
+
+def setup_gdb(options):
+ python_paths = set()
+
+ if not shutil.which('gdb'):
+ return python_paths
+
+ bdir = pathlib.Path(options.builddir).resolve()
+ for libpath, gdb_path in [
+ (os.path.join("subprojects", "gstreamer", "gst"),
+ os.path.join("subprojects", "gstreamer", "libs", "gst", "helpers")),
+ (os.path.join("subprojects", "glib", "gobject"), None),
+ (os.path.join("subprojects", "glib", "glib"), None)]:
+
+ if not gdb_path:
+ gdb_path = libpath
+
+ autoload_path = (pathlib.Path(bdir) / 'gdb-auto-load').joinpath(*bdir.parts[1:]) / libpath
+ autoload_path.mkdir(parents=True, exist_ok=True)
+ for gdb_helper in glob.glob(str(bdir / gdb_path / "*-gdb.py")):
+ python_paths.add(str(bdir / gdb_path))
+ python_paths.add(os.path.join(options.srcdir, gdb_path))
+ try:
+ if os.name == 'nt':
+ shutil.copy(gdb_helper, str(autoload_path / os.path.basename(gdb_helper)))
+ else:
+ os.symlink(gdb_helper, str(autoload_path / os.path.basename(gdb_helper)))
+ except (FileExistsError, shutil.SameFileError):
+ pass
+
+ gdbinit_line = 'add-auto-load-scripts-directory {}\n'.format(bdir / 'gdb-auto-load')
+ try:
+ with open(os.path.join(options.srcdir, '.gdbinit'), 'r') as f:
+ if gdbinit_line in f.readlines():
+ return python_paths
+ except FileNotFoundError:
+ pass
+
+ with open(os.path.join(options.srcdir, '.gdbinit'), 'a') as f:
+ f.write(gdbinit_line)
+
+ return python_paths
+
+
+def is_bash_completion_available(options):
+ return os.path.exists(os.path.join(options.builddir, 'subprojects/gstreamer/data/bash-completion/helpers/gst'))
+
+