gst-env: Don't put helper binaries in PATH

Check if the executable would be installed into bindir before adding
it to PATH in the uninstalled shell.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-build/issues/67
This commit is contained in:
Nirbheek Chauhan 2019-12-19 03:39:37 +05:30
parent 245baadbce
commit bc1c337c77

View file

@ -13,6 +13,7 @@ import sys
import tempfile
import pathlib
import signal
from pathlib import PurePath
from distutils.sysconfig import get_python_lib
from distutils.util import strtobool
@ -96,6 +97,24 @@ def is_library_target_and_not_plugin(target, filename):
return False
return True
def is_binary_target_and_in_path(target, filename, bindir):
if target['type'] != 'executable':
return False
if not target['installed']:
return False
# Check if this file installed by this target is installed to bindir
for install_filename in listify(target['install_filename']):
if install_filename.endswith(os.path.basename(filename)):
break
else:
# None of the installed files in the target correspond to the built
# filename, so skip
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:
@ -206,10 +225,14 @@ def get_subprocess_env(options, gst_version):
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('\\', '/')
libdir = PurePath(libdir)
prefix, = [o['value'] for o in build_options if o['name'] == 'prefix']
bindir, = [o['value'] for o in build_options if o['name'] == 'bindir']
prefix = PurePath(prefix)
bindir = prefix / bindir
global GSTPLUGIN_FILEPATH_REG_TEMPLATE
GSTPLUGIN_FILEPATH_REG_TEMPLATE = GSTPLUGIN_FILEPATH_REG_TEMPLATE.format(libdir=libdir)
GSTPLUGIN_FILEPATH_REG_TEMPLATE = GSTPLUGIN_FILEPATH_REG_TEMPLATE.format(libdir=libdir.as_posix())
for target in targets:
filenames = listify(target['filename'])
@ -227,7 +250,7 @@ def get_subprocess_env(options, gst_version):
prepend_env_var(env, lib_path_envvar,
os.path.join(options.builddir, root),
options.sysroot)
elif target['type'] == 'executable' and target['installed']:
elif is_binary_target_and_in_path(target, filename, bindir):
paths.add(os.path.join(options.builddir, root))
with open(os.path.join(options.builddir, 'GstPluginsPath.json')) as f: