forked from mmp/pbrt-v3
-
Notifications
You must be signed in to change notification settings - Fork 4
/
compile.py
executable file
·86 lines (62 loc) · 1.67 KB
/
compile.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
81
82
83
84
85
86
#!/usr/bin/env python3
import os
import subprocess
import shutil
import sys
# Directory detection =========================================================
rootDir = os.path.abspath(os.path.dirname(__file__))
# Utilities ===================================================================
def run(cmd):
print(">>> {}".format(" ".join(cmd)))
code = subprocess.call(cmd, shell=False)
if code != 0:
print("Failed.")
sys.exit(1)
# Main script =================================================================
def main():
os.chdir(rootDir)
# Main build --------------------------------------------------------------
run([
"rm",
"-rf",
"build"
])
run([
"mkdir",
"build"
])
buildDir = os.path.join(rootDir, "build")
os.chdir(buildDir)
# Cmake
run([
"cmake",
".."
])
# Make
run([
"make",
"-j4"
])
# npm install -------------------------------------------------------------
npmDirs = ["bin", "gui", "tools"]
for npmDir in npmDirs:
fullDir = os.path.join(rootDir, npmDir)
os.chdir(fullDir)
run(["npm", "install"])
# cpfm build --------------------------------------------------------------
cpfmDir = os.path.join(rootDir, "tools", "cpfm")
cpfmBuildDir = os.path.join(cpfmDir, "build")
if os.path.exists(cpfmBuildDir):
shutil.rmtree(cpfmBuildDir)
os.mkdir(cpfmBuildDir)
os.chdir(cpfmBuildDir)
run([
"cmake",
"../cpfm"
])
run([
"make",
"-j4"
])
# Run =========================================================================
main()