Port gen_wrapper.py to Python 3

Basically the only issue left out is that Python3 is much more picky
on file encoding, and some Valve headers are not UTF-8. Ignoring
errors is enough to get everything fixed.
This commit is contained in:
Giovanni Mascellani 2020-11-04 12:56:12 +01:00 committed by Andrew Eikum
parent 04af5e3d79
commit 16992af05c

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python2 #!/usr/bin/env python3
#NOTE: If you make modifications here, consider whether they should #NOTE: If you make modifications here, consider whether they should
#be duplicated in ../vrclient/gen_wrapper.py #be duplicated in ../vrclient/gen_wrapper.py
@ -1215,7 +1215,10 @@ prog = re.compile("^#define\s*(\w*)\s*\"(.*)\"")
for sdkver in sdk_versions: for sdkver in sdk_versions:
iface_versions = {} iface_versions = {}
for f in os.listdir("steamworks_sdk_%s" % sdkver): for f in os.listdir("steamworks_sdk_%s" % sdkver):
x = open("steamworks_sdk_%s/%s" % (sdkver, f), "r") # Some files from Valve have non-UTF-8 stuff in the comments
# (typically the copyright symbol); therefore we ignore UTF-8
# encoding errors
x = open("steamworks_sdk_%s/%s" % (sdkver, f), "r", errors='replace')
for l in x: for l in x:
if "define STEAM" in l and "_VERSION" in l: if "define STEAM" in l and "_VERSION" in l:
result = prog.match(l) result = prog.match(l)