common.get_meson(): use MESONINTROSPECT if present

If meson has set this, it takes priority over whatever
we may find in PATH.
This commit is contained in:
Mathieu Duponchelle 2017-12-18 18:46:14 +01:00
parent c6c09b7317
commit d106c2f8df

View file

@ -2,6 +2,7 @@ import argparse
import os
import shutil
import subprocess
import shlex
ROOTDIR = os.path.abspath(os.path.dirname(__file__))
@ -58,6 +59,21 @@ def get_meson():
if os.path.exists(meson):
return meson
mesonintrospect = os.environ.get('MESONINTROSPECT', '')
for comp in shlex.split (mesonintrospect):
# mesonintrospect might look like "/usr/bin/python /somewhere/meson introspect",
# 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'):
meson = os.path.join(mesondir, 'meson.py')
else:
meson = os.path.join(mesondir, 'meson')
if os.path.exists (meson):
return meson
meson = accept_command(["meson.py", "meson"])
return meson