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-11-07 21:17:39 +00:00
|
|
|
from common import accept_command
|
2016-10-10 23:14:50 +00:00
|
|
|
|
2016-09-05 17:47:50 +00:00
|
|
|
|
2016-10-26 20:44:19 +00:00
|
|
|
PROJECTNAME = "GStreamer build"
|
2016-09-05 17:47:50 +00:00
|
|
|
|
|
|
|
ROOTDIR = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
|
|
|
|
2016-10-20 20:41:08 +00:00
|
|
|
def get_meson():
|
2016-10-14 09:53:21 +00:00
|
|
|
meson = os.path.join(ROOTDIR, 'meson', 'meson.py')
|
2016-10-20 20:41:08 +00:00
|
|
|
if os.path.exists(meson):
|
2016-10-26 22:39:49 +00:00
|
|
|
mesonconf = os.path.join(ROOTDIR, 'meson', 'mesonconf.py')
|
|
|
|
return meson, mesonconf
|
2016-09-05 17:47:50 +00:00
|
|
|
|
2016-10-26 22:39:49 +00:00
|
|
|
return accept_command(["meson.py", "meson"]), accept_command(["mesonconf.py", "mesonconf"])
|
2016-09-05 17:47:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
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-26 22:39:49 +00:00
|
|
|
meson, mesonconf = get_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)
|
2016-10-26 22:39:49 +00:00
|
|
|
subprocess.check_call([sys.executable, mesonconf] + get_configs(meson), cwd=build_dir)
|
|
|
|
print("\nYou can now build GStreamer and its various subprojects running:\n"
|
2016-10-20 20:53:08 +00:00
|
|
|
" $ ninja -C %s" % 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.')
|
|
|
|
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)
|