forked from recastnavigation/recastnavigation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_recast_bindings_c2z.py
148 lines (125 loc) · 3.42 KB
/
generate_recast_bindings_c2z.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import os
import sys
import subprocess
class Header:
def __init__(self, filepath, includes=None):
self.filepath = filepath
self.includes = includes or []
headers = [
###
### RECAST
###
Header(
os.path.join("Recast", "Include", "Recast.h"),
),
# Header(
# os.path.join("Recast", "Include", "RecastAlloc.h"),
# ),
# Header(
# os.path.join("Recast", "Include", "RecastAssert.h"),
# ),
###
### DETOUR
###
Header(
os.path.join("Detour", "Include", "DetourAlloc.h"),
),
Header(
os.path.join("Detour", "Include", "DetourAssert.h"),
),
Header(
os.path.join("Detour", "Include", "DetourCommon.h"),
),
# Header(
# No need to bind this I think.
# os.path.join("Detour", "Include", "DetourMath.h"),
# ),
Header(
os.path.join("Detour", "Include", "DetourNavMesh.h"),
),
Header(
os.path.join("Detour", "Include", "DetourNavMeshBuilder.h"),
),
Header(
os.path.join("Detour", "Include", "DetourNavMeshQuery.h"),
),
Header(
os.path.join("Detour", "Include", "DetourNode.h"),
),
Header(
os.path.join("Detour", "Include", "DetourStatus.h"),
),
###
### DETOUR TILE CACHE
###
Header(
os.path.join("DetourTileCache", "Include", "DetourTileCache.h"),
[os.path.join("..", "..", "Detour", "Include")],
),
###
### DETOUR CROWD
###
Header(
os.path.join("DetourCrowd", "Include", "DetourPathCorridor.h"),
[os.path.join("..", "..", "Detour", "Include")],
),
]
def get_headers():
return headers
def generate(c2z_exe_path, project_root_path, header):
print("/////////////////////////")
print("Generating", header.filepath)
print("Includes:", header.includes)
print("Root path:", project_root_path)
print("c2z path:", c2z_exe_path)
header_filename = os.path.join(project_root_path, header.filepath)
print("Full path:", header_filename)
header_folderpath = os.path.dirname(header_filename)
os.chdir(header_folderpath)
print("In folder:", header_folderpath)
print("-------------------------")
run_params = []
run_params.append(c2z_exe_path)
for include_path in header.includes:
run_params.append("-I" + include_path)
run_params.append(header_filename)
subprocess.run(
run_params,
cwd=".",
capture_output=False,
text=True,
)
print("\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\")
# Back down to external...
os.chdir(project_root_path)
def build_c2z():
# assume we're at /external
os.chdir("c2z")
print("Building c2z...")
subprocess.run(
[
"zig",
"build",
# "-Dtarget=native-native-msvc",
# "--summary",
# "failures",
],
cwd=".",
capture_output=False,
text=True,
)
# Back down to external...
os.chdir("..")
if __name__ == "__main__":
# Default to Tides of Revival's setup
c2z_exe_path = os.path.abspath(
os.path.join(os.getcwd(), "..", "c2z", "zig-out", "bin", "c2z")
)
if len(sys.argv) > 1:
c2z_exe_path = sys.argv[1]
project_root_path = os.getcwd()
for header in get_headers():
generate(c2z_exe_path, project_root_path, header)
print("")
print("Done, press enter!")
a = input()