-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathconfigure
executable file
·90 lines (71 loc) · 2.48 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env python3
"""Script for generating the Makefiles."""
import argparse
import os
import sys
import shutil
import subprocess
PROJECTNAME = "gst-plugins-vr"
ROOTDIR = os.path.abspath(os.path.dirname(__file__))
MAKEFILE_TMPL = """all:
%(tab)scd %(build_dir)s && %(ninja)s -k 100; %(ninja)s
install:
%(tab)scd %(build_dir)s && DESTDIR="${DESTDIR}" %(ninja)s install
check:
%(tab)scd %(build_dir)s && %(ninja)s test
uninstalled:
%(tab)scd %(build_dir)s && %(ninja)s uninstalled
clean:
%(tab)srm -Rf %(build_dir)s
%(tab)srm Makefile
"""
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 configure_meson(args):
"""Configures meson and generate the Makefile."""
meson = accept_command(["meson", "meson.py"])
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)
os.chdir(build_dir)
try:
subprocess.check_call([meson, "../"] + args)
except subprocess.CalledProcessError as e:
print("EXIT meson return %s" % e.returncode)
print("Makefile won't be generated")
exit(1)
with open(os.path.join(ROOTDIR, "Makefile"), "w") as makefile:
makefile.write(MAKEFILE_TMPL %
{"build_dir": build_dir,
"ninja": ninja,
"tab": " "})
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)