Commit b5bbc5a6 authored by thakis@chromium.org's avatar thakis@chromium.org

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
parent 8e6e1e69
...@@ -57,7 +57,7 @@ def GetFileList(root): ...@@ -57,7 +57,7 @@ def GetFileList(root):
for base, _, files in os.walk(root): for base, _, files in os.walk(root):
paths = [os.path.join(base, f) for f in files] paths = [os.path.join(base, f) for f in files]
file_list.extend(x.lower() for x in paths) 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): def MakeTimestampsFileName(root):
...@@ -93,7 +93,7 @@ def CalculateHash(root): ...@@ -93,7 +93,7 @@ def CalculateHash(root):
digest = hashlib.sha1() digest = hashlib.sha1()
for path in file_list: for path in file_list:
digest.update(path) digest.update(str(path).replace('/', '\\'))
with open(path, 'rb') as f: with open(path, 'rb') as f:
digest.update(f.read()) digest.update(f.read())
return digest.hexdigest() return digest.hexdigest()
......
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