2016-11-19 13:18:33 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""Script for generating the Makefiles."""
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
from common import get_meson
|
|
|
|
from common import accept_command
|
|
|
|
|
|
|
|
|
|
|
|
PROJECTNAME = "GStreamer build"
|
|
|
|
|
|
|
|
ROOTDIR = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
|
|
|
|
|
|
|
class GstBuildConfigurer:
|
|
|
|
|
|
|
|
def __init__(self, options, args):
|
|
|
|
self.options = options
|
|
|
|
self.args = args
|
|
|
|
|
|
|
|
def get_configs(self):
|
2016-12-14 00:36:25 +00:00
|
|
|
if self.options.no_error:
|
|
|
|
return []
|
2016-11-19 13:18:33 +00:00
|
|
|
return ['--werror']
|
|
|
|
|
|
|
|
def configure_meson(self):
|
|
|
|
if not self.options.reconfigure:
|
|
|
|
if os.path.exists(ROOTDIR + "/build/build.ninja"):
|
|
|
|
print("Not reconfiguring")
|
|
|
|
return True
|
|
|
|
|
2018-08-10 21:20:14 +00:00
|
|
|
try:
|
|
|
|
meson = get_meson()
|
|
|
|
except RuntimeError:
|
2016-11-19 13:18:33 +00:00
|
|
|
print("Install mesonbuild to build %s: http://mesonbuild.com/\n"
|
|
|
|
"You can simply install it with:\n"
|
|
|
|
" $ sudo pip3 install meson" % PROJECTNAME)
|
|
|
|
return False
|
|
|
|
|
|
|
|
ninja = accept_command(["ninja", "ninja-build"])
|
|
|
|
if not ninja:
|
|
|
|
print("Install ninja-build to build %s: https://ninja-build.org/"
|
|
|
|
% PROJECTNAME)
|
|
|
|
return False
|
|
|
|
|
|
|
|
build_dir = os.path.join(ROOTDIR, "build")
|
|
|
|
shutil.rmtree(build_dir, True)
|
|
|
|
os.mkdir(build_dir)
|
|
|
|
|
|
|
|
try:
|
2018-08-10 21:20:14 +00:00
|
|
|
subprocess.check_call(meson + ["../"] + self.args + self.get_configs(),
|
|
|
|
cwd=build_dir)
|
2016-11-19 13:18:33 +00:00
|
|
|
print("\nYou can now build GStreamer and its various subprojects running:\n"
|
2017-01-03 17:29:52 +00:00
|
|
|
" $ {} -C {!r}".format(os.path.basename(ninja), build_dir))
|
2016-11-19 13:18:33 +00:00
|
|
|
except subprocess.CalledProcessError:
|
|
|
|
return False
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
def setup(self):
|
|
|
|
return self.configure_meson()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
parser = argparse.ArgumentParser(description='Process some integers.')
|
|
|
|
parser.add_argument("--reconfigure", action='store_true',
|
|
|
|
default=False, help='Force a full reconfiguration'
|
|
|
|
' meaning the build/ folder is removed.'
|
|
|
|
' You can also use `ninja reconfigure` to just'
|
|
|
|
' make sure meson is rerun but the build folder'
|
|
|
|
' is kept.')
|
2016-12-14 00:36:25 +00:00
|
|
|
parser.add_argument("--no-error", action='store_true',
|
|
|
|
default=False, help="Do not error out on warnings")
|
2016-11-19 13:18:33 +00:00
|
|
|
|
|
|
|
options, args = parser.parse_known_args()
|
|
|
|
configurer = GstBuildConfigurer(options, args)
|
|
|
|
exit(not configurer.setup())
|