2016-09-05 17:47:50 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""Script for generating the Makefiles."""
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
|
2016-10-10 23:14:50 +00:00
|
|
|
from common import git
|
|
|
|
from common import Colors
|
|
|
|
|
2016-09-05 17:47:50 +00:00
|
|
|
|
|
|
|
PROJECTNAME = "GStreamer 'all'"
|
|
|
|
|
|
|
|
ROOTDIR = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
|
|
|
|
2016-10-14 09:53:21 +00:00
|
|
|
def get_meson(update_meson):
|
|
|
|
meson = os.path.join(ROOTDIR, 'meson', 'meson.py')
|
|
|
|
if update_meson or not os.path.exists(meson):
|
|
|
|
print("Updating meson submodule... ", end='')
|
|
|
|
sys.stdout.flush()
|
|
|
|
git('submodule', 'update', '--init', repository_path=ROOTDIR)
|
|
|
|
print("DONE")
|
2016-09-05 17:47:50 +00:00
|
|
|
|
2016-10-14 09:53:21 +00:00
|
|
|
return meson
|
2016-09-05 17:47:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
def accept_command(commands):
|
|
|
|
"""Checks if @command --version works."""
|
|
|
|
for command in commands:
|
|
|
|
try:
|
|
|
|
subprocess.check_output([command, "--version"])
|
|
|
|
return command
|
|
|
|
except FileNotFoundError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
def get_configs(meson):
|
2016-10-14 09:53:21 +00:00
|
|
|
return ['-D', 'werror=true']
|
2016-09-05 17:47:50 +00:00
|
|
|
|
|
|
|
|
2016-10-14 09:53:21 +00:00
|
|
|
def configure_meson(args, options):
|
2016-09-05 17:47:50 +00:00
|
|
|
"""Configures meson and generate the Makefile."""
|
2016-10-14 09:53:21 +00:00
|
|
|
meson = get_meson(options.update_meson)
|
2016-09-05 17:47:50 +00:00
|
|
|
if not meson:
|
|
|
|
print("Install mesonbuild to build %s: http://mesonbuild.com/\n"
|
|
|
|
"You can simply install it with:\n"
|
|
|
|
" $ sudo pip3 install meson" % PROJECTNAME)
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
ninja = accept_command(["ninja", "ninja-build"])
|
|
|
|
if not ninja:
|
|
|
|
print("Install ninja-build to build %s: https://ninja-build.org/"
|
|
|
|
% PROJECTNAME)
|
|
|
|
exit(1)
|
|
|
|
|
|
|
|
build_dir = os.path.join(ROOTDIR, "build")
|
|
|
|
shutil.rmtree(build_dir, True)
|
|
|
|
os.mkdir(build_dir)
|
|
|
|
|
|
|
|
try:
|
2016-10-17 14:42:07 +00:00
|
|
|
subprocess.check_call([sys.executable, meson, "../"] + args, cwd=build_dir)
|
|
|
|
subprocess.check_call([sys.executable, os.path.join(ROOTDIR, 'meson', 'mesonconf.py')]
|
2016-10-14 09:53:21 +00:00
|
|
|
+ get_configs(meson), cwd=build_dir)
|
2016-09-14 13:42:52 +00:00
|
|
|
except subprocess.CalledProcessError as e:
|
|
|
|
print("EXIT meson return %s" % e.returncode)
|
2016-09-05 17:47:50 +00:00
|
|
|
exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
parser = argparse.ArgumentParser(description='Process some integers.')
|
|
|
|
parser.add_argument("--no-reconfigure", action='store_true',
|
|
|
|
default=False, help='Avoid removing the build dir'
|
|
|
|
' if not necessary.')
|
2016-10-14 09:53:21 +00:00
|
|
|
parser.add_argument("-u", "--update-meson", action='store_true',
|
|
|
|
default=False, help='Do not update meson')
|
2016-09-05 17:47:50 +00:00
|
|
|
options, args = parser.parse_known_args()
|
|
|
|
if options.no_reconfigure:
|
|
|
|
if os.path.exists(
|
|
|
|
ROOTDIR + "/build/build.ninja") and os.path.exists(
|
|
|
|
ROOTDIR + "/Makefile"):
|
|
|
|
print("Not reconfiguring")
|
|
|
|
exit(0)
|
|
|
|
|
2016-10-14 09:53:21 +00:00
|
|
|
configure_meson(args, options)
|