2 """Script for generating the Makefiles."""
10 from common import get_meson
11 from common import accept_command
14 PROJECTNAME = "GStreamer build"
16 ROOTDIR = os.path.abspath(os.path.dirname(__file__))
19 class GstBuildConfigurer:
21 def __init__(self, options, args):
22 self.options = options
25 def get_configs(self):
26 if self.options.werror:
30 def configure_meson(self):
31 if not self.options.reconfigure:
32 if os.path.exists(ROOTDIR + "/build/build.ninja"):
33 print("Not reconfiguring")
39 print("Install mesonbuild to build %s: http://mesonbuild.com/\n"
40 "You can simply install it with:\n"
41 " $ sudo pip3 install meson" % PROJECTNAME)
44 ninja = accept_command(["ninja", "ninja-build"])
46 print("Install ninja-build to build %s: https://ninja-build.org/"
50 build_dir = os.path.join(ROOTDIR, "build")
51 shutil.rmtree(build_dir, True)
55 subprocess.check_call(meson + ["../"] + self.args + self.get_configs(),
57 print("\nYou can now build GStreamer and its various subprojects running:\n"
58 " $ {} -C {!r}".format(os.path.basename(ninja), build_dir))
59 except subprocess.CalledProcessError:
65 return self.configure_meson()
69 if __name__ == "__main__":
70 parser = argparse.ArgumentParser(description='Process some integers.')
71 parser.add_argument("--reconfigure", action='store_true',
72 default=False, help='Force a full reconfiguration'
73 ' meaning the build/ folder is removed.'
74 ' You can also use `ninja reconfigure` to just'
75 ' make sure meson is rerun but the build folder'
77 parser.add_argument("--werror", action='store_true',
78 default=False, help="Do not error out on warnings")
80 options, args = parser.parse_known_args()
81 configurer = GstBuildConfigurer(options, args)
82 exit(not configurer.setup())