forked from gcherchi/InteractiveAndRobustMeshBooleans
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
94 lines (79 loc) · 2.84 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
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
87
88
89
90
91
92
93
94
import os
import sys
import subprocess
import argparse
import shutil
from pathlib import Path
from os import walk
# EmscriptenSDKPath = "C:/APPS/emsdk"
EmscriptenSDKPath = os.environ.get('EMSCRIPTEN')
BUILD_TYPE = "Debug"
def build_windows():
compilePath = "build/windows"
cmake_cmd = [
"cmake",
"-B", compilePath,
]
result = subprocess.run(cmake_cmd)
if result.returncode != 0:
return
build_cmd = ["cmake", "--build", compilePath, "--config", BUILD_TYPE,]
result = subprocess.run(build_cmd)
if result.returncode != 0:
return
dstPath = "build/OUT/runtimes/win-x64/native/"
os.makedirs(os.path.dirname(dstPath), exist_ok=True)
shutil.copy2(f"{compilePath}/{BUILD_TYPE}/cmb.dll", dstPath)
if BUILD_TYPE == "Debug":
shutil.copy2(f"{compilePath}/{BUILD_TYPE}/cmb.pdb", dstPath)
def build_wasm():
compilePath = "build/wasm"
cmake_cmd = [
"cmake",
"-B", compilePath,
"-GNinja",
f"-DCMAKE_BUILD_TYPE={BUILD_TYPE}",
f"-DCMAKE_TOOLCHAIN_FILE={EmscriptenSDKPath}/cmake/Modules/Platform/Emscripten.cmake",
f"-DCMAKE_CROSSCOMPILING_EMULATOR={EmscriptenSDKPath}/node/16.20.0_64bit/bin/node.exe",
]
result = subprocess.run(cmake_cmd)
if result.returncode != 0:
return
build_cmd = ["cmake", "--build", compilePath, "--target", "cmb"]
result = subprocess.run(build_cmd)
if result.returncode != 0:
return
outputPath = "build/OUT/build/wasm-binaries"
if not os.path.isdir(outputPath):
os.makedirs(outputPath)
arScriptStr = f"CREATE {outputPath}/cmb.a\n"
arScriptStr += f"ADDLIB {compilePath}/libcmb.a\n"
arScriptStr += f"ADDLIB {compilePath}/shewchuk_predicates/libshewchuk_predicates.a\n"
#arScriptStr += f"ADDLIB {compilePath}/clang_20.0_cxx20_32_release/libtbb.a\n"
arScriptStr += "SAVE\nEND\n"
arScriptFileName = "build/wasm/cmb.ar"
with open(arScriptFileName, 'w') as f:
f.write(arScriptStr)
ar_cmd = [
f"{EmscriptenSDKPath}/emar.bat",
"-M",
f"<{arScriptFileName}"
]
result = subprocess.run(ar_cmd)
if result.returncode != 0:
return
#########
#dstPath = "build/OUT/build/wasm-binaries/cmb.a"
#os.makedirs(os.path.dirname(dstPath), exist_ok=True)
#shutil.copy2(f"{compilePath}/libcmb.a", dstPath)
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--verbose", action="store_true")
parser.add_argument("--emscripten_sdk", help = "Path to the Emscripten SDK install dir")
args = parser.parse_args()
build_windows()
if True:
if EmscriptenSDKPath is None:
print("Warning: EMSCRIPTEN environment variable not set.\nPlease install Emscripten and set the EMSCRIPTEN environment variable to the path of installation.")
else:
print(EmscriptenSDKPath)
build_wasm()