-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.py
41 lines (32 loc) · 1.19 KB
/
make.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
#!/usr/bin/python
import platform, os, argparse, shutil
def system(cmd):
if os.system(cmd) != 0:
raise "Failed to execute cmd:", cmd
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--release", action="store_true", help = "release build")
parser.add_argument("--clean", action="store_true", help = "clean tmp building files")
args = parser.parse_args()
if (args.clean):
if (os.path.exists("tmp")):
shutil.rmtree("tmp")
if (os.path.exists("lib")):
shutil.rmtree("lib")
print "remove tmp building files"
return
if args.release:
build_type = "-DCMAKE_BUILD_TYPE=Release"
else:
build_type = "-DCMAKE_BUILD_TYPE=Debug"
if not os.path.isdir("tmp"):
os.mkdir("tmp")
os.chdir("tmp")
if platform.system() == "Windows":
system("cmake -G \"Visual Studio 12 Win64\" .. %s %s" % (build_type, "-DPLATFORM=win32"))
system("cmake --build . --config Release")
elif platform.system() == "Linux":
system("cmake -G \"Unix Makefiles\" .. %s %s" % (build_type, "-DPLATFORM=linux_x64"))
system("make")
if __name__ == '__main__':
main()