-
Notifications
You must be signed in to change notification settings - Fork 120
Expand file tree
/
Copy pathcompileBindings.py
More file actions
executable file
·63 lines (54 loc) · 1.96 KB
/
compileBindings.py
File metadata and controls
executable file
·63 lines (54 loc) · 1.96 KB
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
#!/usr/bin/python3
import os
import sys
from Common import ocIncludePaths, additionalIncludePaths
import subprocess
import multiprocessing
from functools import partial
from argparse import ArgumentParser
libraryBasePath = "/opencascade.js/build/bindings"
def buildOneFile(args, item):
if not os.path.exists(item + ".o"):
print("building " + item)
sys.stdout.flush()
command = [
"emcc",
"-flto",
"-fexceptions",
"-sDISABLE_EXCEPTION_CATCHING=0",
"-DIGNORE_NO_ATOMICS=1",
"-DOCCT_NO_PLUGINS",
"-frtti",
"-DHAVE_RAPIDJSON",
"-Os",
# "-g3",
# "-gsource-map",
# "--source-map-base=http://localhost:8080",
"-pthread" if args["threading"] == "multi-threaded" else "",
*list(map(lambda x: "-I" + x, ocIncludePaths + additionalIncludePaths)),
"-c", item,
]
subprocess.check_call([
*command,
"-o", item + ".o",
])
else:
print("file " + item + ".o already exists, skipping")
sys.stdout.flush()
def compileCustomCodeBindings(args):
filesToBuild = []
for dirpath, dirnames, filenames in os.walk(libraryBasePath + "/myMain.h"):
filesToBuild.extend(map(lambda x: dirpath + "/" + x, filter(lambda x: x.endswith(".cpp"), filenames)))
with multiprocessing.Pool(processes=int(multiprocessing.cpu_count() / 1)) as p:
p.map(partial(buildOneFile, args), sorted(filesToBuild))
if __name__ == "__main__":
parser = ArgumentParser()
parser.add_argument(dest="threading", choices=["single-threaded", "multi-threaded"], help="Build in single vs. multi-threaded mode")
args = parser.parse_args()
filesToBuild = []
for dirpath, dirnames, filenames in os.walk(libraryBasePath):
filesToBuild.extend(map(lambda x: dirpath + "/" + x, filter(lambda x: x.endswith(".cpp"), filenames)))
with multiprocessing.Pool(processes=int(multiprocessing.cpu_count() / 1)) as p:
p.map(partial(buildOneFile, {
"threading": args.threading,
}), sorted(filesToBuild))