mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-01-14 07:38:11 +03:00
vrclient: Parse all include files at once.
This commit is contained in:
parent
57ea5353ee
commit
a7d8aabc0d
@ -72,7 +72,7 @@ sdk_versions = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
files = [
|
files = [
|
||||||
("openvr.h",
|
("ivrclientcore.h",
|
||||||
[ #classes
|
[ #classes
|
||||||
"IVRApplications",
|
"IVRApplications",
|
||||||
"IVRChaperone",
|
"IVRChaperone",
|
||||||
@ -94,17 +94,12 @@ files = [
|
|||||||
"IVRTrackedCamera",
|
"IVRTrackedCamera",
|
||||||
"IVRHeadsetView",
|
"IVRHeadsetView",
|
||||||
"IVROverlayView",
|
"IVROverlayView",
|
||||||
|
"IVRClientCore",
|
||||||
], [ #vrclient-allocated structs
|
], [ #vrclient-allocated structs
|
||||||
"RenderModel_t",
|
"RenderModel_t",
|
||||||
"RenderModel_TextureMap_t",
|
"RenderModel_TextureMap_t",
|
||||||
]
|
]
|
||||||
),
|
),
|
||||||
("ivrclientcore.h",
|
|
||||||
[ #classes
|
|
||||||
"IVRClientCore",
|
|
||||||
], [ #vrclient-allocated structs
|
|
||||||
]
|
|
||||||
),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
next_is_size_structs = [
|
next_is_size_structs = [
|
||||||
@ -1376,10 +1371,17 @@ int main(void)
|
|||||||
|
|
||||||
prog = re.compile("^.*const\s*char.* \*?(\w*)_Version.*\"(.*)\"")
|
prog = re.compile("^.*const\s*char.* \*?(\w*)_Version.*\"(.*)\"")
|
||||||
for sdkver in sdk_versions:
|
for sdkver in sdk_versions:
|
||||||
|
print(f'parsing SDK version {sdkver}...')
|
||||||
|
sdkdir = f'openvr_{sdkver}'
|
||||||
|
|
||||||
|
sources = {}
|
||||||
iface_versions = {}
|
iface_versions = {}
|
||||||
print("sdkver is: " + sdkver)
|
has_vrclientcore = False
|
||||||
for f in os.listdir("openvr_%s" % sdkver):
|
for file in os.listdir(sdkdir):
|
||||||
x = open("openvr_%s/%s" % (sdkver, f), "r")
|
x = open(f"{sdkdir}/{file}", "r")
|
||||||
|
if file == "ivrclientcore.h":
|
||||||
|
has_vrclientcore = True
|
||||||
|
|
||||||
for l in x:
|
for l in x:
|
||||||
if "_Version" in l:
|
if "_Version" in l:
|
||||||
result = prog.match(l)
|
result = prog.match(l)
|
||||||
@ -1387,17 +1389,42 @@ for sdkver in sdk_versions:
|
|||||||
iface, version = result.group(1, 2)
|
iface, version = result.group(1, 2)
|
||||||
iface_versions[iface] = version
|
iface_versions[iface] = version
|
||||||
|
|
||||||
for fname, classes, system_structs in files:
|
if not has_vrclientcore:
|
||||||
# Parse as 32-bit C++
|
source = [f'#include "{sdkdir}/openvr.h"']
|
||||||
input_name = "openvr_%s/%s" % (sdkver, fname)
|
else:
|
||||||
sys.stdout.write("about to parse %s\n" % input_name)
|
source = [f'#include "{sdkdir}/{file}"' for file, _, _ in files]
|
||||||
if not os.path.isfile(input_name):
|
|
||||||
continue
|
sources["source.cpp"] = "\n".join(source)
|
||||||
|
windows_args = ["-D_WIN32", "-fms-extensions", "-Wno-ignored-attributes",
|
||||||
|
"-mms-bitfields", "-U__linux__", "-Wno-incompatible-ms-struct"]
|
||||||
|
windows_args += ['-I' + CLANG_PATH + '/include/']
|
||||||
|
linux_args = ["-DGNUC"]
|
||||||
|
linux_args += ['-I' + CLANG_PATH + '/include/']
|
||||||
|
|
||||||
index = Index.create()
|
index = Index.create()
|
||||||
windows_build = index.parse(input_name, args=['-x', 'c++', '-m32', '-I' + CLANG_PATH + '/include/', '-mms-bitfields', '-U__linux__', '-Wno-incompatible-ms-struct'])
|
|
||||||
windows_build64 = index.parse(input_name, args=['-x', 'c++', '-m64', '-I' + CLANG_PATH + '/include/', '-mms-bitfields', '-U__linux__', '-Wno-incompatible-ms-struct'])
|
linux_build32 = index.parse("source.cpp", args=linux_args + ["-m32"], unsaved_files=sources.items())
|
||||||
tu = index.parse(input_name, args=['-x', 'c++', '-m32', '-std=c++11', '-DGNUC', '-I' + CLANG_PATH + '/include/'])
|
diagnostics = list(linux_build32.diagnostics)
|
||||||
linux_build64 = index.parse(input_name, args=['-x', 'c++', '-m64', '-std=c++11', '-DGNUC', '-I' + CLANG_PATH + '/include/'])
|
for diag in diagnostics: print(diag)
|
||||||
|
assert len(diagnostics) == 0
|
||||||
|
|
||||||
|
linux_build64 = index.parse("source.cpp", args=linux_args + ["-m64"], unsaved_files=sources.items())
|
||||||
|
diagnostics = list(linux_build64.diagnostics)
|
||||||
|
for diag in diagnostics: print(diag)
|
||||||
|
assert len(diagnostics) == 0
|
||||||
|
|
||||||
|
windows_build32 = index.parse("source.cpp", args=windows_args + ["-m32"], unsaved_files=sources.items())
|
||||||
|
diagnostics = list(windows_build32.diagnostics)
|
||||||
|
for diag in diagnostics: print(diag)
|
||||||
|
assert len(diagnostics) == 0
|
||||||
|
|
||||||
|
windows_build64 = index.parse("source.cpp", args=windows_args + ["-m64"], unsaved_files=sources.items())
|
||||||
|
diagnostics = list(windows_build64.diagnostics)
|
||||||
|
for diag in diagnostics: print(diag)
|
||||||
|
assert len(diagnostics) == 0
|
||||||
|
|
||||||
|
classes = sum([e for _, e, _ in files], [])
|
||||||
|
system_structs = sum([e for _, _, e in files], [])
|
||||||
|
|
||||||
def enumerate_structs(cursor, vr_only=False):
|
def enumerate_structs(cursor, vr_only=False):
|
||||||
for child in cursor.get_children():
|
for child in cursor.get_children():
|
||||||
@ -1407,18 +1434,13 @@ for sdkver in sdk_versions:
|
|||||||
yield child
|
yield child
|
||||||
|
|
||||||
windows_structs32 = dict(reversed([(child.type.spelling, child.type) for child
|
windows_structs32 = dict(reversed([(child.type.spelling, child.type) for child
|
||||||
in enumerate_structs(windows_build.cursor)]))
|
in enumerate_structs(windows_build32.cursor)]))
|
||||||
windows_structs64 = dict(reversed([(child.type.spelling, child.type) for child
|
windows_structs64 = dict(reversed([(child.type.spelling, child.type) for child
|
||||||
in enumerate_structs(windows_build64.cursor)]))
|
in enumerate_structs(windows_build64.cursor)]))
|
||||||
linux_structs64 = dict(reversed([(child.type.spelling, child.type) for child
|
linux_structs64 = dict(reversed([(child.type.spelling, child.type) for child
|
||||||
in enumerate_structs(linux_build64.cursor)]))
|
in enumerate_structs(linux_build64.cursor)]))
|
||||||
|
|
||||||
diagnostics = list(tu.diagnostics)
|
for child in enumerate_structs(linux_build32.cursor, vr_only=True):
|
||||||
if len(diagnostics) > 0:
|
|
||||||
print('There were parse errors')
|
|
||||||
pprint.pprint(diagnostics)
|
|
||||||
else:
|
|
||||||
for child in enumerate_structs(tu.cursor, vr_only=True):
|
|
||||||
if child.kind == CursorKind.CLASS_DECL and child.displayname in classes:
|
if child.kind == CursorKind.CLASS_DECL and child.displayname in classes:
|
||||||
handle_class(sdkver, child)
|
handle_class(sdkver, child)
|
||||||
if child.kind in [CursorKind.STRUCT_DECL, CursorKind.CLASS_DECL]:
|
if child.kind in [CursorKind.STRUCT_DECL, CursorKind.CLASS_DECL]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user