From b5bbc5a6e50e6564c4a892caedf5a622b22ccf30 Mon Sep 17 00:00:00 2001 From: "thakis@chromium.org" Date: Tue, 11 Aug 2015 20:16:20 +0000 Subject: [PATCH] Make `python build/vs_toolchain.py update` mostly work on non-Windows. 1. GetFileList() returns a list of path\names on Windows but of path/names on non-Windows. To not perturb existing hashes, I guess the hashing code should do path.replace('/', '\\') before hashing. 2. GetFileList() returns a sorted list of filenames, and \ compares pretty different than / (the former is less than all numbers while the latter is greater, for example). So replace / with \\ for sorting too. With this change, OS X produces the same file hash as Windows. The script still early-exits on non-Windows, so no visible change yet. BUG=495204 Review URL: https://codereview.chromium.org/1287543005 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@296271 0039d316-1c4b-4281-b951-d872f2087c98 --- win_toolchain/get_toolchain_if_necessary.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win_toolchain/get_toolchain_if_necessary.py b/win_toolchain/get_toolchain_if_necessary.py index 0a589ec7d4..7187bf491b 100755 --- a/win_toolchain/get_toolchain_if_necessary.py +++ b/win_toolchain/get_toolchain_if_necessary.py @@ -57,7 +57,7 @@ def GetFileList(root): for base, _, files in os.walk(root): paths = [os.path.join(base, f) for f in files] file_list.extend(x.lower() for x in paths) - return sorted(file_list) + return sorted(file_list, key=lambda s: s.replace('/', '\\')) def MakeTimestampsFileName(root): @@ -93,7 +93,7 @@ def CalculateHash(root): digest = hashlib.sha1() for path in file_list: - digest.update(path) + digest.update(str(path).replace('/', '\\')) with open(path, 'rb') as f: digest.update(f.read()) return digest.hexdigest()