mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-15 22:01:27 +00:00
4c2f97525f
It is necessary now that we explicitly run it through the python interpreter.
84 lines
2.5 KiB
Python
Executable file
84 lines
2.5 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""Script for generating the Makefiles."""
|
|
|
|
import argparse
|
|
import os
|
|
import sys
|
|
import shutil
|
|
import subprocess
|
|
|
|
from common import git
|
|
from common import Colors
|
|
|
|
|
|
PROJECTNAME = "GStreamer build"
|
|
|
|
ROOTDIR = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
|
|
def get_meson():
|
|
meson = os.path.join(ROOTDIR, 'meson', 'meson.py')
|
|
if os.path.exists(meson):
|
|
mesonconf = os.path.join(ROOTDIR, 'meson', 'mesonconf.py')
|
|
return meson, mesonconf
|
|
|
|
return accept_command(["meson.py", "meson"]), accept_command(["mesonconf.py", "mesonconf"])
|
|
|
|
|
|
def accept_command(commands):
|
|
"""Search @commands and returns the first found absolute path."""
|
|
for command in commands:
|
|
command = shutil.which(command)
|
|
if command:
|
|
return command
|
|
|
|
return None
|
|
|
|
|
|
def get_configs(meson):
|
|
return ['-D', 'werror=true']
|
|
|
|
|
|
def configure_meson(args, options):
|
|
"""Configures meson and generate the Makefile."""
|
|
meson, mesonconf = get_meson()
|
|
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:
|
|
subprocess.check_call([sys.executable, meson, "../"] + args, cwd=build_dir)
|
|
subprocess.check_call([sys.executable, mesonconf] + get_configs(meson), cwd=build_dir)
|
|
print("\nYou can now build GStreamer and its various subprojects running:\n"
|
|
" $ ninja -C %s" % build_dir)
|
|
except subprocess.CalledProcessError as e:
|
|
print("EXIT meson return %s" % e.returncode)
|
|
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)
|
|
|
|
configure_meson(args, options)
|