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") worktree_subdir = os.path.join(worktree_dir, "subprojects")
meson = get_meson() meson = get_meson()
installed_s = subprocess.check_output([sys.executable, meson, 'introspect', installed_s = subprocess.check_output(meson + ['introspect', options.builddir, '--projectinfo'])
options.builddir, '--projectinfo'])
for subproj in json.loads(installed_s.decode())["subprojects"]: for subproj in json.loads(installed_s.decode())["subprojects"]:
repo_name = subproj["name"] repo_name = subproj["name"]
if not repo_name.startswith("gst"): if not repo_name.startswith("gst"):

View file

@ -51,13 +51,12 @@ def accept_command(commands):
command = shutil.which(command) command = shutil.which(command)
if command: if command:
return command return command
return None return None
def get_meson(): def get_meson():
meson = os.path.join(ROOTDIR, 'meson', 'meson.py') meson = os.path.join(ROOTDIR, 'meson', 'meson.py')
if os.path.exists(meson): if os.path.exists(meson):
return meson return [sys.executable, meson]
mesonintrospect = os.environ.get('MESONINTROSPECT', '') mesonintrospect = os.environ.get('MESONINTROSPECT', '')
for comp in shlex.split (mesonintrospect): for comp in shlex.split (mesonintrospect):
@ -65,15 +64,16 @@ def get_meson():
# let's not get tricked # let's not get tricked
if 'python' in os.path.basename (comp): if 'python' in os.path.basename (comp):
continue continue
if os.path.exists (comp): if os.path.exists(comp):
mesondir = os.path.dirname(comp) if comp.endswith('.py'):
if mesonintrospect.endswith('.py') or mesonintrospect.endswith('.py introspect'): return [sys.executable, comp]
meson = os.path.join(mesondir, 'meson.py')
else: else:
meson = os.path.join(mesondir, 'meson') return [comp]
if os.path.exists (meson):
return meson
meson = accept_command(["meson.py", "meson"]) meson = accept_command(['meson.py'])
if meson:
return 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) setup_python_env(options, env)
meson = get_meson() 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()) targets = json.loads(targets_s.decode())
paths = set() paths = set()
mono_paths = set() mono_paths = set()
@ -111,9 +111,8 @@ def get_subprocess_env(options):
presets = set() presets = set()
encoding_targets = set() encoding_targets = set()
pkg_dirs = set() pkg_dirs = set()
if '--installed' in subprocess.check_output([sys.executable, meson, 'introspect', '-h']).decode(): if '--installed' in subprocess.check_output(meson + ['introspect', '-h']).decode():
installed_s = subprocess.check_output([sys.executable, meson, 'introspect', installed_s = subprocess.check_output(meson + ['introspect', options.builddir, '--installed'])
options.builddir, '--installed'])
for path, installpath in json.loads(installed_s.decode()).items(): for path, installpath in json.loads(installed_s.decode()).items():
if path.endswith('.prs'): if path.endswith('.prs'):
presets.add(os.path.dirname(path)) presets.add(os.path.dirname(path))

View file

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