-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder.py
60 lines (54 loc) · 1.64 KB
/
builder.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
# -------------------------
# Cmake Project Template
# Build Script Helper
# -------------------------
import argparse
import subprocess
import sys
numOpts = 5
optMessage = """Choose Build Option:
1) MacOS
2) Windows
3) IOS
4) Android
5) Web (WASM)
"""
outDirs = {
1 : "out/macos/",
5: "out/web/"
}
pathToBrowser = "/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
Release = "-DCMAKE_BUILD_TYPE=Release"
Debug = "-DCMAKE_BUILD_TYPE=Debug"
def main():
choice = None
if (len(sys.argv) > 1 and sys.argv[1].isdigit()):
choice = sys.argv[1]
else:
print(optMessage)
while (True):
choice = input("");
if (choice.isdigit() and int(choice) in range(1, numOpts+1)):
break
print(f'\r\033[A')
if (choice == "1"):
print("MacOS")
subprocess.run(["cmake", Debug, "-S", "./", "-B", outDirs[1] + "/build"])
subprocess.run(["make", "-C", outDirs[1] + "build"])
subprocess.run(["make", "install", "-C", outDirs[1] + "build"])
elif (choice == "2"):
print("Windows")
elif (choice == "3"):
print("IOS")
elif (choice == "4"):
print("Android")
elif (choice == "5"):
print("Web (WASM)")
subprocess.run(["emcmake", "cmake", Debug, "-S", "./", "-B", outDirs[5] + "build"])
subprocess.run(["make", "-C", "build"])
subprocess.run(["make", "install", "-C", outDirs[5] + "build"])
subprocess.run(["emrun", outDirs[5] + "build/src/app.html", "--browser", pathToBrowser])
else:
print("Invalid Choice")
if __name__ == "__main__":
main()