scripts: Fix fetching of meson command to run

Don't assume that meson is always a python script, on Windows it can
be (and soon will almost always be) an executable.

See: Meson MSI installer and https://github.com/mesonbuild/meson/pull/4004
This commit is contained in:
Nirbheek Chauhan 2018-08-11 02:50:14 +05:30
parent 1e21d789ae
commit 783e6a226d
4 changed files with 21 additions and 22 deletions

View file

@ -21,8 +21,7 @@ def checkout_subprojects(worktree_dir, branch):
worktree_subdir = os.path.join(worktree_dir, "subprojects")
meson = get_meson()
installed_s = subprocess.check_output([sys.executable, meson, 'introspect',
options.builddir, '--projectinfo'])
installed_s = subprocess.check_output(meson + ['introspect', options.builddir, '--projectinfo'])
for subproj in json.loads(installed_s.decode())["subprojects"]:
repo_name = subproj["name"]
if not repo_name.startswith("gst"):

View file

@ -51,13 +51,12 @@ def accept_command(commands):
command = shutil.which(command)
if command:
return command
return None
def get_meson():
meson = os.path.join(ROOTDIR, 'meson', 'meson.py')
if os.path.exists(meson):
return meson
return [sys.executable, meson]
mesonintrospect = os.environ.get('MESONINTROSPECT', '')
for comp in shlex.split (mesonintrospect):
@ -65,15 +64,16 @@ def get_meson():
# let's not get tricked
if 'python' in os.path.basename (comp):
continue
if os.path.exists (comp):
mesondir = os.path.dirname(comp)
if mesonintrospect.endswith('.py') or mesonintrospect.endswith('.py introspect'):
meson = os.path.join(mesondir, 'meson.py')
if os.path.exists(comp):
if comp.endswith('.py'):
return [sys.executable, comp]
else:
meson = os.path.join(mesondir, 'meson')
if os.path.exists (meson):
return meson
return [comp]
meson = accept_command(["meson.py", "meson"])
return meson
meson = accept_command(['meson.py'])
if meson:
return [sys.executable, meson]
meson = accept_command(['meson'])
if meson:
return [meson]
raise RuntimeError('Could not find Meson')

View file

@ -76,7 +76,7 @@ def get_subprocess_env(options):
setup_python_env(options, env)
meson = get_meson()
targets_s = subprocess.check_output([sys.executable, meson, 'introspect', options.builddir, '--targets'])
targets_s = subprocess.check_output(meson + ['introspect', options.builddir, '--targets'])
targets = json.loads(targets_s.decode())
paths = set()
mono_paths = set()
@ -111,9 +111,8 @@ def get_subprocess_env(options):
presets = set()
encoding_targets = set()
pkg_dirs = set()
if '--installed' in subprocess.check_output([sys.executable, meson, 'introspect', '-h']).decode():
installed_s = subprocess.check_output([sys.executable, meson, 'introspect',
options.builddir, '--installed'])
if '--installed' in subprocess.check_output(meson + ['introspect', '-h']).decode():
installed_s = subprocess.check_output(meson + ['introspect', options.builddir, '--installed'])
for path, installpath in json.loads(installed_s.decode()).items():
if path.endswith('.prs'):
presets.add(os.path.dirname(path))

View file

@ -33,8 +33,9 @@ class GstBuildConfigurer:
print("Not reconfiguring")
return True
meson = get_meson()
if not meson:
try:
meson = get_meson()
except RuntimeError:
print("Install mesonbuild to build %s: http://mesonbuild.com/\n"
"You can simply install it with:\n"
" $ sudo pip3 install meson" % PROJECTNAME)
@ -51,8 +52,8 @@ class GstBuildConfigurer:
os.mkdir(build_dir)
try:
subprocess.check_call(
[sys.executable, meson, "../"] + self.args + self.get_configs(), cwd=build_dir)
subprocess.check_call(meson + ["../"] + self.args + self.get_configs(),
cwd=build_dir)
print("\nYou can now build GStreamer and its various subprojects running:\n"
" $ {} -C {!r}".format(os.path.basename(ninja), build_dir))
except subprocess.CalledProcessError: