-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmake.py
executable file
·80 lines (62 loc) · 1.84 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
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
#!/usr/local/bin/python3
"""
A script for generating makefiles from CMakeLists.txt
"""
import os
import platform
import sys
import shutil
def make():
# simple make
extra_flags = ""
if platform.system() == "Windows":
# for now, MinGW should be used, MSVC may be supported in the future
extra_flags = '-G "MinGW Makefiles"'
os.system("cmake -B release {}".format(extra_flags))
os.system("cmake -B debug -D CMAKE_BUILD_TYPE=Debug {}".format(extra_flags))
print("See CMakeLists.txt for all targets")
def clean():
_clean("build")
_clean("debug")
_clean("release")
_clean("xcode")
def _clean(folder: str):
if os.path.exists(folder):
shutil.rmtree(folder)
def test():
if not os.path.exists("debug/"):
make()
if platform.system() == "Windows":
# TODO: fix it for Windows
os.system("cd debug && mingw32-make.exe test_pazusoba && test_pazusoba.exe")
else:
os.system("cd debug && make test_pazusoba && ./test_pazusoba")
def binary():
if not os.path.exists("release/"):
make()
if platform.system() == "Windows":
# TODO: fix it for Windows
os.system("cd release && mingw32-make.exe pazusoba_binary")
else:
os.system("cd release && make pazusoba_binary")
def xcode():
if platform.system() == "Darwin":
os.system("cmake -B xcode -G Xcode -D CMAKE_BUILD_TYPE=Debug")
os.system("cp -r support xcode")
os.system("open xcode/pazusoba.xcodeproj")
argv = sys.argv
argc = len(argv)
if argc <= 1:
make()
elif argc == 2:
option = argv[1]
if option == "test":
test()
elif option == "clean":
clean()
elif option == "xcode":
xcode()
elif option == "binary":
binary()
else:
exit("Unknown command - (test, clean, xcode, binary) avilable")