mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 13:11:06 +00:00
af5ee95a5b
This is new in meson 0.40. Makes sure we find and use the mesonintrospect from the same location as our meson, and not some other meson version that just happens to be in the path. We might be using meson directly from a checkout, for example. https://bugzilla.gnome.org/show_bug.cgi?id=781110
77 lines
2.1 KiB
Python
77 lines
2.1 KiB
Python
import argparse
|
|
import os
|
|
import shutil
|
|
import subprocess
|
|
|
|
|
|
ROOTDIR = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
|
class Colors:
|
|
HEADER = '\033[95m'
|
|
OKBLUE = '\033[94m'
|
|
OKGREEN = '\033[92m'
|
|
WARNING = '\033[93m'
|
|
FAIL = '\033[91m'
|
|
ENDC = '\033[0m'
|
|
|
|
force_disable = False
|
|
|
|
@classmethod
|
|
def disable(cls):
|
|
cls.HEADER = ''
|
|
cls.OKBLUE = ''
|
|
cls.OKGREEN = ''
|
|
cls.WARNING = ''
|
|
cls.FAIL = ''
|
|
cls.ENDC = ''
|
|
|
|
@classmethod
|
|
def enable(cls):
|
|
if cls.force_disable:
|
|
return
|
|
|
|
cls.HEADER = '\033[95m'
|
|
cls.OKBLUE = '\033[94m'
|
|
cls.OKGREEN = '\033[92m'
|
|
cls.WARNING = '\033[93m'
|
|
cls.FAIL = '\033[91m'
|
|
cls.ENDC = '\033[0m'
|
|
|
|
|
|
|
|
def git(*args, repository_path='.'):
|
|
return subprocess.check_output(["git"] + list(args), cwd=repository_path,
|
|
stderr=subprocess.STDOUT).decode()
|
|
|
|
def accept_command(commands):
|
|
"""Search @commands and returns the first found absolute path."""
|
|
for command in 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):
|
|
mesonconf = os.path.join(ROOTDIR, 'meson', 'mesonconf.py')
|
|
mesonintrospect = os.path.join(ROOTDIR, 'meson', 'mesonintrospect.py')
|
|
return meson, mesonconf, mesonintrospect
|
|
|
|
mesonintrospect = os.environ.get('MESONINTROSPECT', None)
|
|
if mesonintrospect and os.path.exists(mesonintrospect):
|
|
mesondir = os.path.dirname(mesonintrospect)
|
|
if mesonintrospect.endswith('.py'):
|
|
meson = os.path.join(mesondir, 'meson.py')
|
|
mesonconf = os.path.join(mesondir, 'mesonconf.py')
|
|
else:
|
|
meson = os.path.join(mesondir, 'meson')
|
|
mesonconf = os.path.join(mesondir, 'mesonconf')
|
|
else:
|
|
meson = accept_command(["meson.py", "meson"])
|
|
mesonconf = accept_command(["mesonconf.py", "mesonconf"])
|
|
mesonintrospect = accept_command(["mesonintrospect.py", "mesonintrospect"])
|
|
|
|
return meson, mesonconf, mesonintrospect
|