Commit 5f9def8b authored by Bruce Dawson's avatar Bruce Dawson Committed by Commit Bot

Fix vs_toolchain.py for Python 3

vs_toolchain.py gets a directory listing for win_sdk_dir\bin and then
sorts it by converting the 10.x.x.x directory names to tuples of
integers. This fails on Python 3 because int and str types are not
comparable so directories with non-integral (non-version) names caused
comparison failures when compared against integral (version) names. This
change filters out the unwanted names before sorting instead of after
sorting, which lets this work on Python 3 (tested by running manually).

A misleading variable name was also changed.

This was reported by a pdfium user.

Change-Id: Ifb0accd831945c6d0eb44e838071b8ddd609ddb2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2309454
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Bruce Dawson <brucedawson@chromium.org>
Reviewed-by: default avatarEdward Lesmes <ehmaldonado@chromium.org>
Cr-Commit-Position: refs/heads/master@{#790446}
parent db4d98f0
...@@ -307,17 +307,16 @@ def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, suffix): ...@@ -307,17 +307,16 @@ def _CopyUCRTRuntime(target_dir, source_dir, target_cpu, suffix):
if not suffix.startswith('.'): if not suffix.startswith('.'):
# ucrtbased.dll is located at {win_sdk_dir}/bin/{a.b.c.d}/{target_cpu}/ # ucrtbased.dll is located at {win_sdk_dir}/bin/{a.b.c.d}/{target_cpu}/
# ucrt/. # ucrt/.
sdk_redist_root = os.path.join(win_sdk_dir, 'bin') sdk_bin_root = os.path.join(win_sdk_dir, 'bin')
sdk_bin_sub_dirs = os.listdir(sdk_redist_root) sdk_bin_sub_dirs = glob.glob(os.path.join(sdk_bin_root, '10.*'))
# Select the most recent SDK if there are multiple versions installed. # Select the most recent SDK if there are multiple versions installed.
_SortByHighestVersionNumberFirst(sdk_bin_sub_dirs) _SortByHighestVersionNumberFirst(sdk_bin_sub_dirs)
for directory in sdk_bin_sub_dirs: for directory in sdk_bin_sub_dirs:
sdk_redist_root_version = os.path.join(sdk_redist_root, directory) sdk_redist_root_version = os.path.join(sdk_bin_root, directory)
if not os.path.isdir(sdk_redist_root_version): if not os.path.isdir(sdk_redist_root_version):
continue continue
if re.match(r'10\.\d+\.\d+\.\d+', directory): source_dir = os.path.join(sdk_redist_root_version, target_cpu, 'ucrt')
source_dir = os.path.join(sdk_redist_root_version, target_cpu, 'ucrt') break
break
_CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix), _CopyRuntimeImpl(os.path.join(target_dir, 'ucrtbase' + suffix),
os.path.join(source_dir, 'ucrtbase' + suffix)) os.path.join(source_dir, 'ucrtbase' + suffix))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment