mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-02-10 13:48:49 +03:00
vrclient: Use a dict for SDK sources / class mapping.
CW-Bug-Id: #22729
This commit is contained in:
parent
ff2999e563
commit
73db1a9176
@ -69,39 +69,41 @@ SDK_VERSIONS = [
|
|||||||
"0.9.0",
|
"0.9.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
SDK_SOURCES = [
|
SDK_SOURCES = {
|
||||||
("ivrclientcore.h",
|
"ivrclientcore.h": [
|
||||||
[ #classes
|
[ #classes
|
||||||
"IVRApplications",
|
"IVRApplications",
|
||||||
"IVRChaperone",
|
"IVRChaperone",
|
||||||
"IVRChaperoneSetup",
|
"IVRChaperoneSetup",
|
||||||
"IVRCompositor",
|
"IVRCompositor",
|
||||||
"IVRControlPanel",
|
"IVRControlPanel",
|
||||||
"IVRDriverManager",
|
"IVRDriverManager",
|
||||||
"IVRExtendedDisplay",
|
"IVRExtendedDisplay",
|
||||||
"IVRNotifications",
|
"IVRNotifications",
|
||||||
"IVRInput",
|
"IVRInput",
|
||||||
"IVRIOBuffer",
|
"IVRIOBuffer",
|
||||||
"IVRMailbox",
|
"IVRMailbox",
|
||||||
"IVROverlay",
|
"IVROverlay",
|
||||||
"IVRRenderModels",
|
"IVRRenderModels",
|
||||||
"IVRResources",
|
"IVRResources",
|
||||||
"IVRScreenshots",
|
"IVRScreenshots",
|
||||||
"IVRSettings",
|
"IVRSettings",
|
||||||
"IVRSystem",
|
"IVRSystem",
|
||||||
"IVRTrackedCamera",
|
"IVRTrackedCamera",
|
||||||
"IVRHeadsetView",
|
"IVRHeadsetView",
|
||||||
"IVROverlayView",
|
"IVROverlayView",
|
||||||
"IVRClientCore",
|
"IVRClientCore",
|
||||||
], [ #vrclient-allocated structs
|
], [ #vrclient-allocated structs
|
||||||
"RenderModel_t",
|
"RenderModel_t",
|
||||||
"RenderModel_TextureMap_t",
|
"RenderModel_TextureMap_t",
|
||||||
]
|
],
|
||||||
),
|
],
|
||||||
]
|
}
|
||||||
|
|
||||||
SDK_CLASSES = {klass: source for source, klasses in SDK_SOURCES.items()
|
SDK_CLASSES = {klass: source for source, value in SDK_SOURCES.items()
|
||||||
for klass in klasses}
|
for klass in value[0]}
|
||||||
|
SDK_STRUCTS = {klass: source for source, value in SDK_SOURCES.items()
|
||||||
|
for klass in value[1]}
|
||||||
|
|
||||||
STRUCTS_NEXT_IS_SIZE = [
|
STRUCTS_NEXT_IS_SIZE = [
|
||||||
"VREvent_t",
|
"VREvent_t",
|
||||||
@ -451,11 +453,11 @@ def handle_method(cfile, classname, winclassname, cppname, method, cpp, cpp_h, e
|
|||||||
while real_type.kind == TypeKind.POINTER:
|
while real_type.kind == TypeKind.POINTER:
|
||||||
real_type = real_type.get_pointee()
|
real_type = real_type.get_pointee()
|
||||||
if param.type.kind == TypeKind.POINTER:
|
if param.type.kind == TypeKind.POINTER:
|
||||||
if strip_ns(param.type.get_pointee().get_canonical().spelling) in system_structs:
|
if strip_ns(param.type.get_pointee().get_canonical().spelling) in SDK_STRUCTS:
|
||||||
do_unwrap = (strip_ns(param.type.get_pointee().get_canonical().spelling), param.spelling)
|
do_unwrap = (strip_ns(param.type.get_pointee().get_canonical().spelling), param.spelling)
|
||||||
typename = "win" + do_unwrap[0] + "_" + display_sdkver(sdkver) + " *"
|
typename = "win" + do_unwrap[0] + "_" + display_sdkver(sdkver) + " *"
|
||||||
elif param.type.get_pointee().get_canonical().kind == TypeKind.POINTER and \
|
elif param.type.get_pointee().get_canonical().kind == TypeKind.POINTER and \
|
||||||
strip_ns(param.type.get_pointee().get_pointee().get_canonical().spelling) in system_structs:
|
strip_ns(param.type.get_pointee().get_pointee().get_canonical().spelling) in SDK_STRUCTS:
|
||||||
do_wrap = (strip_ns(param.type.get_pointee().get_pointee().get_canonical().spelling), param.spelling)
|
do_wrap = (strip_ns(param.type.get_pointee().get_pointee().get_canonical().spelling), param.spelling)
|
||||||
typename = "win" + do_wrap[0] + "_" + display_sdkver(sdkver) + " **"
|
typename = "win" + do_wrap[0] + "_" + display_sdkver(sdkver) + " **"
|
||||||
elif real_type.get_canonical().kind == TypeKind.RECORD and \
|
elif real_type.get_canonical().kind == TypeKind.RECORD and \
|
||||||
@ -917,7 +919,7 @@ def handle_struct(sdkver, struct):
|
|||||||
which.add(LIN_TO_WIN)
|
which.add(LIN_TO_WIN)
|
||||||
which.add(WIN_TO_LIN)
|
which.add(WIN_TO_LIN)
|
||||||
|
|
||||||
if strip_ns(struct.displayname) in system_structs:
|
if strip_ns(struct.displayname) in SDK_STRUCTS:
|
||||||
which.add(WRAPPERS)
|
which.add(WRAPPERS)
|
||||||
|
|
||||||
if len(which) == 0:
|
if len(which) == 0:
|
||||||
@ -1352,7 +1354,8 @@ for sdkver in SDK_VERSIONS:
|
|||||||
if not has_vrclientcore:
|
if not has_vrclientcore:
|
||||||
source = [f'#include "{sdkdir}/openvr.h"']
|
source = [f'#include "{sdkdir}/openvr.h"']
|
||||||
else:
|
else:
|
||||||
source = [f'#include "{sdkdir}/{file}"' for file, _, _ in SDK_SOURCES]
|
source = [f'#include "{sdkdir}/{file}"'
|
||||||
|
for file in SDK_SOURCES.keys()]
|
||||||
|
|
||||||
sources["source.cpp"] = "\n".join(source)
|
sources["source.cpp"] = "\n".join(source)
|
||||||
windows_args = ["-D_WIN32", "-fms-extensions", "-Wno-ignored-attributes",
|
windows_args = ["-D_WIN32", "-fms-extensions", "-Wno-ignored-attributes",
|
||||||
@ -1383,9 +1386,6 @@ for sdkver in SDK_VERSIONS:
|
|||||||
for diag in diagnostics: print(diag)
|
for diag in diagnostics: print(diag)
|
||||||
assert len(diagnostics) == 0
|
assert len(diagnostics) == 0
|
||||||
|
|
||||||
classes = sum([e for _, e, _ in SDK_SOURCES], [])
|
|
||||||
system_structs = sum([e for _, _, e in SDK_SOURCES], [])
|
|
||||||
|
|
||||||
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():
|
||||||
if child.kind == CursorKind.NAMESPACE and child.displayname == "vr":
|
if child.kind == CursorKind.NAMESPACE and child.displayname == "vr":
|
||||||
@ -1401,7 +1401,7 @@ for sdkver in SDK_VERSIONS:
|
|||||||
in enumerate_structs(linux_build64.cursor)]))
|
in enumerate_structs(linux_build64.cursor)]))
|
||||||
|
|
||||||
for child in enumerate_structs(linux_build32.cursor, vr_only=True):
|
for child in enumerate_structs(linux_build32.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 SDK_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]:
|
||||||
handle_struct(sdkver, child)
|
handle_struct(sdkver, child)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user