2016-10-10 23:14:50 +00:00
|
|
|
import argparse
|
2016-11-19 21:01:44 +00:00
|
|
|
import os
|
2016-11-07 21:17:39 +00:00
|
|
|
import shutil
|
2016-10-10 23:14:50 +00:00
|
|
|
import subprocess
|
|
|
|
|
2016-11-19 21:01:44 +00:00
|
|
|
|
|
|
|
ROOTDIR = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
|
|
|
|
2016-10-10 23:14:50 +00:00
|
|
|
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'
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-10-11 00:05:39 +00:00
|
|
|
def git(*args, repository_path='.'):
|
|
|
|
return subprocess.check_output(["git"] + list(args), cwd=repository_path,
|
2016-10-10 23:14:50 +00:00
|
|
|
stderr=subprocess.STDOUT).decode()
|
2016-11-07 21:17:39 +00:00
|
|
|
|
|
|
|
def accept_command(commands):
|
2017-01-03 17:23:18 +00:00
|
|
|
"""Search @commands and returns the first found absolute path."""
|
2016-11-07 21:17:39 +00:00
|
|
|
for command in commands:
|
2017-01-03 17:23:18 +00:00
|
|
|
command = shutil.which(command)
|
|
|
|
if command:
|
2016-11-07 21:17:39 +00:00
|
|
|
return command
|
|
|
|
|
|
|
|
return None
|
2016-11-19 21:01:44 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
return accept_command(["meson.py", "meson"]), accept_command(["mesonconf.py", "mesonconf"]), \
|
|
|
|
accept_command(["mesonintrospect.py", "mesonintrospect"])
|