uninstalled: Take into account -good pkgconfig uninstalled file
[platform/upstream/gstreamer.git] / setup.py
1 #!/usr/bin/env python3
2 """Script for generating the Makefiles."""
3
4 import argparse
5 import os
6 import sys
7 import shutil
8 import subprocess
9
10 from common import get_meson
11 from common import accept_command
12
13
14 PROJECTNAME = "GStreamer build"
15
16 ROOTDIR = os.path.abspath(os.path.dirname(__file__))
17
18
19 class GstBuildConfigurer:
20
21     def __init__(self, options, args):
22         self.options = options
23         self.args = args
24
25     def get_configs(self):
26         if self.options.no_error:
27             return []
28         return ['--werror']
29
30     def configure_meson(self):
31         if not self.options.reconfigure:
32             if os.path.exists(ROOTDIR + "/build/build.ninja"):
33                 print("Not reconfiguring")
34                 return True
35
36         meson, mesonconf, mesonintrospect = get_meson()
37         if not meson:
38             print("Install mesonbuild to build %s: http://mesonbuild.com/\n"
39                   "You can simply install it with:\n"
40                   "    $ sudo pip3 install meson" % PROJECTNAME)
41             return False
42
43         ninja = accept_command(["ninja", "ninja-build"])
44         if not ninja:
45             print("Install ninja-build to build %s: https://ninja-build.org/"
46                   % PROJECTNAME)
47             return False
48
49         build_dir = os.path.join(ROOTDIR, "build")
50         shutil.rmtree(build_dir, True)
51         os.mkdir(build_dir)
52
53         try:
54             subprocess.check_call(
55                 [sys.executable, meson, "../"] + self.args + self.get_configs(), cwd=build_dir)
56             print("\nYou can now build GStreamer and its various subprojects running:\n"
57                   " $ {} -C {!r}".format(os.path.basename(ninja), build_dir))
58         except subprocess.CalledProcessError:
59             return False
60
61         return True
62
63     def setup(self):
64         return self.configure_meson()
65
66
67
68 if __name__ == "__main__":
69     parser = argparse.ArgumentParser(description='Process some integers.')
70     parser.add_argument("--reconfigure", action='store_true',
71                         default=False, help='Force a full reconfiguration'
72                         ' meaning the build/ folder is removed.'
73                         ' You can also use `ninja reconfigure` to just'
74                         ' make sure meson is rerun but the build folder'
75                         ' is kept.')
76     parser.add_argument("--no-error", action='store_true',
77                         default=False, help="Do not error out on warnings")
78
79     options, args = parser.parse_known_args()
80     configurer = GstBuildConfigurer(options, args)
81     exit(not configurer.setup())