7 ROOTDIR = os.path.abspath(os.path.dirname(__file__))
34 cls.HEADER = '\033[95m'
35 cls.OKBLUE = '\033[94m'
36 cls.OKGREEN = '\033[92m'
37 cls.WARNING = '\033[93m'
43 def git(*args, repository_path='.'):
44 return subprocess.check_output(["git"] + list(args), cwd=repository_path,
45 stderr=subprocess.STDOUT).decode()
47 def accept_command(commands):
48 """Search @commands and returns the first found absolute path."""
49 for command in commands:
50 command = shutil.which(command)
57 meson = os.path.join(ROOTDIR, 'meson', 'meson.py')
58 if os.path.exists(meson):
59 mesonconf = os.path.join(ROOTDIR, 'meson', 'mesonconf.py')
60 mesonintrospect = os.path.join(ROOTDIR, 'meson', 'mesonintrospect.py')
61 return meson, mesonconf, mesonintrospect
63 mesonintrospect = os.environ.get('MESONINTROSPECT', None)
64 if mesonintrospect and os.path.exists(mesonintrospect):
65 mesondir = os.path.dirname(mesonintrospect)
66 if mesonintrospect.endswith('.py'):
67 meson = os.path.join(mesondir, 'meson.py')
68 mesonconf = os.path.join(mesondir, 'mesonconf.py')
70 meson = os.path.join(mesondir, 'meson')
71 mesonconf = os.path.join(mesondir, 'mesonconf')
73 meson = accept_command(["meson.py", "meson"])
74 mesonconf = accept_command(["mesonconf.py", "mesonconf"])
75 mesonintrospect = accept_command(["mesonintrospect.py", "mesonintrospect"])
77 return meson, mesonconf, mesonintrospect