mirror of
https://github.com/ValveSoftware/Proton.git
synced 2025-01-14 07:38:11 +03:00
lsteamclient: Parse all include files at once.
This commit is contained in:
parent
db7e0e7a14
commit
57ea5353ee
@ -932,7 +932,7 @@ def get_iface_version(classname):
|
|||||||
class_versions[classname].append(ver)
|
class_versions[classname].append(ver)
|
||||||
return (ver, False)
|
return (ver, False)
|
||||||
|
|
||||||
def handle_class(sdkver, classnode):
|
def handle_class(sdkver, classnode, file):
|
||||||
children = list(classnode.get_children())
|
children = list(classnode.get_children())
|
||||||
if len(children) == 0:
|
if len(children) == 0:
|
||||||
return
|
return
|
||||||
@ -971,8 +971,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(steamclient);
|
|||||||
cpp.write(f"#include \"steamworks_sdk_{sdkver}/steam_api.h\"\n")
|
cpp.write(f"#include \"steamworks_sdk_{sdkver}/steam_api.h\"\n")
|
||||||
if os.path.isfile(f"steamworks_sdk_{sdkver}/steamnetworkingtypes.h"):
|
if os.path.isfile(f"steamworks_sdk_{sdkver}/steamnetworkingtypes.h"):
|
||||||
cpp.write(f"#include \"steamworks_sdk_{sdkver}/steamnetworkingtypes.h\"\n")
|
cpp.write(f"#include \"steamworks_sdk_{sdkver}/steamnetworkingtypes.h\"\n")
|
||||||
if not fname == "steam_api.h":
|
if not file == "steam_api.h":
|
||||||
cpp.write(f"#include \"steamworks_sdk_{sdkver}/{fname}\"\n")
|
cpp.write(f"#include \"steamworks_sdk_{sdkver}/{file}\"\n")
|
||||||
cpp.write("#pragma pop_macro(\"__cdecl\")\n")
|
cpp.write("#pragma pop_macro(\"__cdecl\")\n")
|
||||||
cpp.write("#include \"steamclient_private.h\"\n")
|
cpp.write("#include \"steamclient_private.h\"\n")
|
||||||
cpp.write("#ifdef __cplusplus\nextern \"C\" {\n#endif\n")
|
cpp.write("#ifdef __cplusplus\nextern \"C\" {\n#endif\n")
|
||||||
@ -1267,55 +1267,74 @@ def handle_struct(sdkver, struct):
|
|||||||
|
|
||||||
prog = re.compile("^#define\s*(\w*)\s*\"(.*)\"")
|
prog = re.compile("^#define\s*(\w*)\s*\"(.*)\"")
|
||||||
for sdkver in sdk_versions:
|
for sdkver in sdk_versions:
|
||||||
|
print(f"parsing SDK version {sdkver}...")
|
||||||
|
sdkdir = f"steamworks_sdk_{sdkver}"
|
||||||
|
|
||||||
|
sources = {}
|
||||||
iface_versions = {}
|
iface_versions = {}
|
||||||
for f in os.listdir(f"steamworks_sdk_{sdkver}"):
|
for file in os.listdir(sdkdir):
|
||||||
# Some files from Valve have non-UTF-8 stuff in the comments
|
# Some files from Valve have non-UTF-8 stuff in the comments
|
||||||
# (typically the copyright symbol); therefore we ignore UTF-8
|
# (typically the copyright symbol); therefore we ignore UTF-8
|
||||||
# encoding errors
|
# encoding errors
|
||||||
x = open(f"steamworks_sdk_{sdkver}/{f}", "r", errors='replace')
|
lines = open(f"{sdkdir}/{file}", "r", errors="replace").readlines()
|
||||||
for l in x:
|
if file == "isteammasterserverupdater.h":
|
||||||
if "define STEAM" in l and "_VERSION" in l:
|
if """#error "This file isn't used any more"\n""" in lines:
|
||||||
result = prog.match(l)
|
sources[f"{sdkdir}/isteammasterserverupdater.h"] = ""
|
||||||
|
|
||||||
|
for line in lines:
|
||||||
|
if "define STEAM" in line and "_VERSION" in line:
|
||||||
|
result = prog.match(line)
|
||||||
if result:
|
if result:
|
||||||
iface, version = result.group(1, 2)
|
iface, version = result.group(1, 2)
|
||||||
iface_versions[iface] = version
|
iface_versions[iface] = version
|
||||||
|
|
||||||
for fname, classes in files:
|
source = [f"""#if __has_include("{sdkdir}/{file}")
|
||||||
input_name = f"steamworks_sdk_{sdkver}/{fname}"
|
#include "{sdkdir}/{file}"
|
||||||
sys.stdout.write(f"about to parse {input_name}\n")
|
#endif""" for file, _ in files]
|
||||||
if not os.path.isfile(input_name):
|
sources["source.cpp"] = "\n".join(source)
|
||||||
continue
|
windows_args = ["-D_WIN32", "-fms-extensions", "-Wno-ignored-attributes",
|
||||||
index = Index.create()
|
"-mms-bitfields", "-U__linux__", "-Wno-incompatible-ms-struct"]
|
||||||
linux_build = index.parse(input_name, args=['-x', 'c++', '-m32', '-I' + CLANG_PATH + '/include/'])
|
windows_args += ['-I' + CLANG_PATH + '/include/']
|
||||||
linux_build64 = index.parse(input_name, args=['-x', 'c++', '-I' + CLANG_PATH + '/include/'])
|
linux_args = ["-DGNUC"]
|
||||||
|
linux_args += ['-I' + CLANG_PATH + '/include/']
|
||||||
|
|
||||||
|
index = Index.create()
|
||||||
|
|
||||||
|
linux_build32 = index.parse("source.cpp", args=linux_args + ["-m32"], unsaved_files=sources.items())
|
||||||
|
diagnostics = list(linux_build32.diagnostics)
|
||||||
|
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
|
||||||
|
|
||||||
diagnostics = list(linux_build.diagnostics)
|
|
||||||
if len(diagnostics) > 0:
|
|
||||||
# Ignore known and harmless issues
|
|
||||||
if not(len(diagnostics) == 1 and "This file isn't used any more" in diagnostics[0].spelling):
|
|
||||||
print('There were parse errors')
|
|
||||||
pprint.pprint(diagnostics)
|
|
||||||
else:
|
|
||||||
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++', '-I' + CLANG_PATH + '/include/', '-mms-bitfields', '-U__linux__', '-Wno-incompatible-ms-struct'])
|
|
||||||
diagnostics = list(windows_build.diagnostics)
|
|
||||||
if len(diagnostics) > 0:
|
|
||||||
print('There were parse errors (windows build)')
|
|
||||||
pprint.pprint(diagnostics)
|
|
||||||
else:
|
|
||||||
linux_structs64 = dict(reversed([(child.spelling, child.type) for child
|
linux_structs64 = dict(reversed([(child.spelling, child.type) for child
|
||||||
in linux_build64.cursor.get_children()]))
|
in linux_build64.cursor.get_children()]))
|
||||||
windows_structs32 = dict(reversed([(child.spelling, child.type) for child
|
windows_structs32 = dict(reversed([(child.spelling, child.type) for child
|
||||||
in windows_build.cursor.get_children()]))
|
in windows_build32.cursor.get_children()]))
|
||||||
windows_structs64 = dict(reversed([(child.spelling, child.type) for child
|
windows_structs64 = dict(reversed([(child.spelling, child.type) for child
|
||||||
in windows_build64.cursor.get_children()]))
|
in windows_build64.cursor.get_children()]))
|
||||||
for child in linux_build.cursor.get_children():
|
|
||||||
|
classes = dict([(klass, file) for file, classes in files for klass in classes])
|
||||||
|
for child in linux_build32.cursor.get_children():
|
||||||
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, classes[child.displayname])
|
||||||
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)
|
||||||
if child.displayname in print_sizes:
|
if child.displayname in print_sizes:
|
||||||
sys.stdout.write(f"size of {child.displayname} is {child.type.get_size()}\n")
|
print("size of %s is %u" % (child.displayname, child.type.get_size()))
|
||||||
|
|
||||||
for f in cpp_files_need_close_brace:
|
for f in cpp_files_need_close_brace:
|
||||||
m = open(f, "a")
|
m = open(f, "a")
|
||||||
|
@ -21,15 +21,15 @@ extern void *create_winISteamAppList_STEAMAPPLIST_INTERFACE_VERSION001(void *);
|
|||||||
extern void *create_winISteamHTMLSurface_STEAMHTMLSURFACE_INTERFACE_VERSION_005(void *);
|
extern void *create_winISteamHTMLSurface_STEAMHTMLSURFACE_INTERFACE_VERSION_005(void *);
|
||||||
extern void *create_winISteamInventory_STEAMINVENTORY_INTERFACE_V003(void *);
|
extern void *create_winISteamInventory_STEAMINVENTORY_INTERFACE_V003(void *);
|
||||||
extern void *create_winISteamVideo_STEAMVIDEO_INTERFACE_V002(void *);
|
extern void *create_winISteamVideo_STEAMVIDEO_INTERFACE_V002(void *);
|
||||||
|
extern void *create_winISteamParentalSettings_STEAMPARENTALSETTINGS_INTERFACE_VERSION001(void *);
|
||||||
extern void *create_winISteamRemotePlay_STEAMREMOTEPLAY_INTERFACE_VERSION001(void *);
|
extern void *create_winISteamRemotePlay_STEAMREMOTEPLAY_INTERFACE_VERSION001(void *);
|
||||||
|
extern void *create_winISteamNetworkingMessages_SteamNetworkingMessages002(void *);
|
||||||
|
extern void *create_winISteamNetworkingSockets_SteamNetworkingSockets012(void *);
|
||||||
|
extern void *create_winISteamNetworkingUtils_SteamNetworkingUtils004(void *);
|
||||||
extern void *create_winISteamAppTicket_STEAMAPPTICKET_INTERFACE_VERSION001(void *);
|
extern void *create_winISteamAppTicket_STEAMAPPTICKET_INTERFACE_VERSION001(void *);
|
||||||
extern void *create_winISteamGameServer_SteamGameServer014(void *);
|
extern void *create_winISteamGameServer_SteamGameServer014(void *);
|
||||||
extern void *create_winISteamGameServerStats_SteamGameServerStats001(void *);
|
extern void *create_winISteamGameServerStats_SteamGameServerStats001(void *);
|
||||||
extern void *create_winISteamGameCoordinator_SteamGameCoordinator001(void *);
|
extern void *create_winISteamGameCoordinator_SteamGameCoordinator001(void *);
|
||||||
extern void *create_winISteamParentalSettings_STEAMPARENTALSETTINGS_INTERFACE_VERSION001(void *);
|
|
||||||
extern void *create_winISteamNetworkingMessages_SteamNetworkingMessages002(void *);
|
|
||||||
extern void *create_winISteamNetworkingSockets_SteamNetworkingSockets012(void *);
|
|
||||||
extern void *create_winISteamNetworkingUtils_SteamNetworkingUtils004(void *);
|
|
||||||
extern void *create_winISteamNetworkingFakeUDPPort_SteamNetworkingFakeUDPPort001(void *);
|
extern void *create_winISteamNetworkingFakeUDPPort_SteamNetworkingFakeUDPPort001(void *);
|
||||||
extern void *create_winISteamInput_SteamInput005(void *);
|
extern void *create_winISteamInput_SteamInput005(void *);
|
||||||
extern void *create_winISteamUGC_STEAMUGC_INTERFACE_VERSION015(void *);
|
extern void *create_winISteamUGC_STEAMUGC_INTERFACE_VERSION015(void *);
|
||||||
|
@ -21,15 +21,15 @@
|
|||||||
{"STEAMHTMLSURFACE_INTERFACE_VERSION_005", &create_winISteamHTMLSurface_STEAMHTMLSURFACE_INTERFACE_VERSION_005},
|
{"STEAMHTMLSURFACE_INTERFACE_VERSION_005", &create_winISteamHTMLSurface_STEAMHTMLSURFACE_INTERFACE_VERSION_005},
|
||||||
{"STEAMINVENTORY_INTERFACE_V003", &create_winISteamInventory_STEAMINVENTORY_INTERFACE_V003},
|
{"STEAMINVENTORY_INTERFACE_V003", &create_winISteamInventory_STEAMINVENTORY_INTERFACE_V003},
|
||||||
{"STEAMVIDEO_INTERFACE_V002", &create_winISteamVideo_STEAMVIDEO_INTERFACE_V002},
|
{"STEAMVIDEO_INTERFACE_V002", &create_winISteamVideo_STEAMVIDEO_INTERFACE_V002},
|
||||||
|
{"STEAMPARENTALSETTINGS_INTERFACE_VERSION001", &create_winISteamParentalSettings_STEAMPARENTALSETTINGS_INTERFACE_VERSION001},
|
||||||
{"STEAMREMOTEPLAY_INTERFACE_VERSION001", &create_winISteamRemotePlay_STEAMREMOTEPLAY_INTERFACE_VERSION001},
|
{"STEAMREMOTEPLAY_INTERFACE_VERSION001", &create_winISteamRemotePlay_STEAMREMOTEPLAY_INTERFACE_VERSION001},
|
||||||
|
{"SteamNetworkingMessages002", &create_winISteamNetworkingMessages_SteamNetworkingMessages002},
|
||||||
|
{"SteamNetworkingSockets012", &create_winISteamNetworkingSockets_SteamNetworkingSockets012},
|
||||||
|
{"SteamNetworkingUtils004", &create_winISteamNetworkingUtils_SteamNetworkingUtils004},
|
||||||
{"STEAMAPPTICKET_INTERFACE_VERSION001", &create_winISteamAppTicket_STEAMAPPTICKET_INTERFACE_VERSION001},
|
{"STEAMAPPTICKET_INTERFACE_VERSION001", &create_winISteamAppTicket_STEAMAPPTICKET_INTERFACE_VERSION001},
|
||||||
{"SteamGameServer014", &create_winISteamGameServer_SteamGameServer014},
|
{"SteamGameServer014", &create_winISteamGameServer_SteamGameServer014},
|
||||||
{"SteamGameServerStats001", &create_winISteamGameServerStats_SteamGameServerStats001},
|
{"SteamGameServerStats001", &create_winISteamGameServerStats_SteamGameServerStats001},
|
||||||
{"SteamGameCoordinator001", &create_winISteamGameCoordinator_SteamGameCoordinator001},
|
{"SteamGameCoordinator001", &create_winISteamGameCoordinator_SteamGameCoordinator001},
|
||||||
{"STEAMPARENTALSETTINGS_INTERFACE_VERSION001", &create_winISteamParentalSettings_STEAMPARENTALSETTINGS_INTERFACE_VERSION001},
|
|
||||||
{"SteamNetworkingMessages002", &create_winISteamNetworkingMessages_SteamNetworkingMessages002},
|
|
||||||
{"SteamNetworkingSockets012", &create_winISteamNetworkingSockets_SteamNetworkingSockets012},
|
|
||||||
{"SteamNetworkingUtils004", &create_winISteamNetworkingUtils_SteamNetworkingUtils004},
|
|
||||||
{"SteamNetworkingFakeUDPPort001", &create_winISteamNetworkingFakeUDPPort_SteamNetworkingFakeUDPPort001},
|
{"SteamNetworkingFakeUDPPort001", &create_winISteamNetworkingFakeUDPPort_SteamNetworkingFakeUDPPort001},
|
||||||
{"SteamInput005", &create_winISteamInput_SteamInput005},
|
{"SteamInput005", &create_winISteamInput_SteamInput005},
|
||||||
{"STEAMUGC_INTERFACE_VERSION015", &create_winISteamUGC_STEAMUGC_INTERFACE_VERSION015},
|
{"STEAMUGC_INTERFACE_VERSION015", &create_winISteamUGC_STEAMUGC_INTERFACE_VERSION015},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user