lsteamclient: Parse SDK versions and ABIs in parallel.

CW-Bug-Id: #22729
This commit is contained in:
Rémi Bernon 2023-09-16 20:13:49 +02:00
parent d4ac89c481
commit 7d61cb59ad

View File

@ -7,6 +7,7 @@ CLANG_PATH='/usr/lib/clang/15'
from clang.cindex import CursorKind, Index, Type, TypeKind from clang.cindex import CursorKind, Index, Type, TypeKind
from collections import namedtuple from collections import namedtuple
import concurrent.futures
import os import os
import re import re
import math import math
@ -98,6 +99,8 @@ SDK_VERSIONS = [
"099u", "099u",
] ]
ABIS = ['u32', 'u64', 'w32', 'w64']
SDK_SOURCES = { SDK_SOURCES = {
"steam_api.h": [ "steam_api.h": [
"ISteamApps", "ISteamApps",
@ -1344,21 +1347,24 @@ def generate(sdkver, records):
for i, sdkver in enumerate(SDK_VERSIONS): for i, sdkver in enumerate(SDK_VERSIONS):
print(f'loading SDKs... {i * 100 // len(SDK_VERSIONS)}%', end='\r') print(f'loading SDKs... {i * 100 // len(SDK_VERSIONS)}%', end='\r')
all_versions[sdkver], all_sources[sdkver] = load(sdkver) all_versions[sdkver], all_sources[sdkver] = load(sdkver)
print(u'loading SDKs... 100%') print('loading SDKs... 100%')
for i, sdkver in enumerate(SDK_VERSIONS): with concurrent.futures.ThreadPoolExecutor() as executor:
print(f'parsing SDKs... {i * 100 // len(SDK_VERSIONS)}%', end='\r') arg0 = [sdkver for sdkver in SDK_VERSIONS for abi in ABIS]
sources = all_sources[sdkver] arg1 = [abi for sdkver in SDK_VERSIONS for abi in ABIS]
records = {} def parse_map(sdkver, abi):
records['u32'] = parse(sources, 'u32') return sdkver, abi, parse(all_sources[sdkver], abi)
records['u64'] = parse(sources, 'u64')
records['w32'] = parse(sources, 'w32')
records['w64'] = parse(sources, 'w64')
all_records[sdkver] = records
print(u'parsing SDKs... 100%')
for sdkver, records in all_records.items(): results = executor.map(parse_map, arg0, arg1)
generate(sdkver, records) for i, result in enumerate(results):
print(f'parsing SDKs... {i * 100 // len(arg0)}%', end='\r')
sdkver, abi, index = result
if sdkver not in all_records: all_records[sdkver] = {}
all_records[sdkver][abi] = index
print('parsing SDKs... 100%')
for sdkver in SDK_VERSIONS:
generate(sdkver, all_records[sdkver])
for f in cpp_files_need_close_brace: for f in cpp_files_need_close_brace: