forked from strfry/qwebrtc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
executable file
·48 lines (40 loc) · 1.62 KB
/
build.py
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
#!/usr/bin/python
import argparse
import os
import shutil
import subprocess
import sys
from multiprocessing import cpu_count
parser = argparse.ArgumentParser()
parser.add_argument("-c", "--clean", help="Force clean build", action="store_true")
parser.add_argument("-r", "--release", help="Build in release mode", action="store_true")
parser.add_argument("-j", "--jobs", help="Specify how many commands can run in parallel", type=int, default=cpu_count())
parser.add_argument("-w", "--buildwebrtc", help="Checkout and build WebRTC", action="store_true")
parser.add_argument("--asan", help="Build with ASAN", action="store_true")
parser.add_argument("--tsan", help="Build with TSAN", action="store_true")
parser.add_argument("--ubsan", help="Build with UBSAN", action="store_true")
args = parser.parse_args()
main_dir = os.path.dirname(os.path.abspath(__file__))
configuration = "Release" if args.release else "Debug"
build_dir = os.path.join(os.path.dirname(main_dir), "out/" + configuration)
if args.clean and os.path.exists(build_dir):
shutil.rmtree(build_dir)
if args.buildwebrtc:
build_args = [main_dir + "/build_webrtc.py"]
if args.release:
build_args.append("-r")
r = subprocess.call(build_args)
if r != 0:
exit(r)
build_args = ["cmake", "-GNinja", "-DCMAKE_BUILD_TYPE=" + configuration]
if args.asan:
build_args.append("-DENABLE_ASAN=ON")
if args.tsan:
build_args.append("-DENABLE_TSAN=ON")
if args.ubsan:
build_args.append("-DENABLE_UBSAN=ON")
build_args.append(main_dir)
r = subprocess.call(build_args)
if r != 0:
exit(r)
exit(subprocess.call("ninja install -j" + str(args.jobs), shell=True))