From b8e9aabd6768b89ef3c83771d394e6c60906a1cb Mon Sep 17 00:00:00 2001 From: Asher Baker Date: Thu, 5 Nov 2015 16:58:50 +0000 Subject: [PATCH] Windows sucks. This may or may not break the Windows build in retaliation. --- tools/buildbot/upload_symbols.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tools/buildbot/upload_symbols.py b/tools/buildbot/upload_symbols.py index 32f1ded3..5b9adb86 100644 --- a/tools/buildbot/upload_symbols.py +++ b/tools/buildbot/upload_symbols.py @@ -37,14 +37,31 @@ lines = out.splitlines() paths = set() roots = {} -for line in lines: +# Lets not even talk about this. +def fixWindowsPath(path): + import ctypes + GetLongPathName = ctypes.windll.kernel32.GetLongPathNameW + buffer = ctypes.create_unicode_buffer(260) + rv = GetLongPathName(path.capitalize(), buffer, 260) + print(rv, buffer.value) + if rv == 0 or rv > 260: + return path + return buffer.value + +for i, line in enumerate(lines): line = line.strip().split(None, 2) if line[0] != 'FILE': continue - path = os.path.dirname(line[2]) + path = line[2] + if os.name == 'nt' and os.path.exists(path): + path = fixWindowsPath(path) + line = ' '.join('FILE', line[1], path) + lines[i] = line + + path = os.path.dirname(path) if path in paths: continue @@ -64,7 +81,9 @@ for line in lines: try: root = runCommand(['git', 'rev-parse', '--show-toplevel']) - root = os.path.normcase(root) + + if os.name == 'nt': + root = fixWindowsPath(os.path.normcase(root)) if root in roots: continue